I have something like this
private void radioButton8_CheckedChanged(object sender, EventArgs e)
{
if (radioButton8.Checked == true)
{ }
}
private void radioButton9_CheckedChanged(object sender, EventArgs e)
{
if (radioButton9.Checked == true)
{ }
}
private void radioButton10_CheckedChanged(object sender, EventArgs e)
{
if (radioButton10.Checked == true)
{}
}
And using ctrl + H i wanna find all text that is similar to
private void radioButtonX_CheckedChanged
where X can be anything
You can use this Regular Expression:
private void radioButton.*?_CheckedChanged
Just remember to tell Sublime Text that this is a Regular Expression (the .* button in the find panel).
Related
I am trying to save a list of backstack pages that are Tombstoned, so that when I navigate back to them, I can compare if they are present in this list. If yes, I'll restore its state.
Currently my code looks like this.
public partial class App : Application
{
public static List<PhoneApplicationPage> TombstonedPages = new List<PhoneApplicationPage>();
private void Application_Activated(object sender, ActivatedEventArgs e)
{
if(!e.IsApplicationInstancePreserved)
{
foreach (JournalEntry j in (Application.Current.RootVisual as PhoneApplicationFrame).BackStack)
{
TombstonedPages.Add(//What should i add here);
}
}
}
}
code in some PhoneApplicationPage
protected override void OnNavigatedTo(NavigationEventArgs e)
{
//checking tombstone
if(e.NavigationMode== NavigationMode.Back && App.TombstonedPages.Contains(this) )
{
//restore state and delete entry from App.TombstonedPages
}
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
if(e.NavigationMode != NavigationMode.Back)
{
//save state
}
}
But I am unable to get a reference of pages from backstack. How should I do this? Is there a different way to do this?
public Constructor1()
{
this.NavigationCacheMode = NavigationCacheMode.Enabled;
}
....
public Constructor2()
{
this.NavigationCacheMode = NavigationCacheMode.Enabled;
HardwareButtons.BackPressed += this.MainPage_BackPressed;
}
private void MainPage_BackPressed(object sender, BackPressedEventArgs e)
{
if(this.Frame.CanGoBack)
{
this.Frame.GoBack();
}
}
After I use the BackButton on my Windows Phone my Application minimizes itself. I have to go to the Task Manager and click on it to bring it back up.
Any suggestions why Frame.GoBack minimizes the Application?
private void MainPage_BackPressed(object sender, BackPressedEventArgs e)
{
if(this.Frame.CanGoBack)
{
e.Handled = true;
this.Frame.GoBack();
}
}
e.Handled = true; was the problem.
void b_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
MessageBoxResult result = MessageBox.Show("A", "MessageBox Example", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
MessageBox.Show(" ....");
}
}
void b_Click(object sender, RoutedEventArgs e)
{
Button btnevent = (Button)sender;
for (int i = 0; i < (Application.Current as App).devices.Length; i++)
if (btnevent.Content.ToString() == (Application.Current as App).devices[i])
{
(Application.Current as App).selectedDevice = i;
NavigationService.Navigate(new Uri("/pages/Buttons.xaml", UriKind.Relative));
}
}
I am working on project and I need to define hold and click events to one button. the problem is click event always fired even i hold on or click the button .
in other words ,, can i disable click event when I hold on the buttons ?
Use tap instead of click in this style
private void Button_OnHold(object sender, GestureEventArgs e)
{
e.Handled = true;
// Your code goes here
}
private void Button_OnTap(object sender, GestureEventArgs e)
{
// Your code goes here
}
After you set Handled property to true click event will not handle your gesture.
I'm developing an windowsphone 8 application.
My goal is to click on a certain button on a website from my code behind (C#).
Is there anyway to achieve this?
Example:
I have a button named 'MyButton" on Mainpage. Then in the event handler:
private void BtnMyButton_Click(object sender, EventArgs e)
{
//click button 'Search' on Google
}
You could register a Javascript function to call the click event.
In codebehind:
protected void BtnMyButton_Click(object sender, EventArgs e)
{
string script = "<script type=\"text/javascript\"> document.getElementById('yourButtonID').onclick(); </script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "searchClick", script);
}
Or if you're using jQuery:
protected void BtnMyButton_Click(object sender, EventArgs e)
{
string script = "<script type=\"text/javascript\"> $('yourButtonID').Click(); </script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "searchClick", script);
}
I've created buttons dynamically, now unable to handle events on it, there is no usefull link on internet..
button.MouseEnter += new EventHandler(button_MouseEnter);
button.MouseLeave += new EventHandler(button_MouseLeave);
...
void button_MouseLeave(object sender, EventArgs e)
{
}
void button_MouseEnter(object sender, EventArgs e)
{
}
This code is not working ...
MouseEnter and MouseLeave are respectively triggered when the mouse pointer hovers on and out of an object. The event you're searching for is Click.
Other than that, your code should work:
button.Click += new RoutedEventHandler(button_Click);
void button_Click(object sender, RoutedEventArgs e)
{
// Whatever
}
Try the MouseLeftButtonDown and MouseLeftButtonUp events. Change the image to the new one in MouseLeftButtonDown and change it back with MouseLeftButtonUp.
So simple, just put this code as it is.
button.MouseEnter += new EventHandler(button_MouseEnter);
button.MouseLeave += new EventHandler(button_MouseLeave);
void button_MouseLeave(object sender, EventArgs e)
{
var brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("/Images/camBlue.png", UriKind.Relative));
Button1.Background = brush;
}
void button_MouseEnter(object sender, EventArgs e)
{
var brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("/Images/camRed.png", UriKind.Relative));
Button1.Background = brush;
}