Im trying to reuse a code that i’ve made for toggleswitch on my application
When the switch is unchecked it fires the code below
private void ToggleSwitch_Unchecked(object sender, RoutedEventArgs e)
{
//Some code here YAY!
}
Works like a charm from the XAML.
<toolkit:ToggleSwitch Margin="0,0,12,0" Content="Allow" Checked="ToggleSwitch_Checked" Unchecked="ToggleSwitch_Unchecked" x:Name="allowGpsSwitch" IsChecked="true" />
Now im trying to call this code from C# as well. I tried a few ways of calling ToggleSwitch_Unchecked code without success.
In resume: I want to call ToggleSwitch_Unchecked from code to execute right away. I know i can make a method for that separately but i want o reuse the same one i made for the event.
is it possible or my thoughts are completely wrong?
Yes, I think your thoughts are wrong. Your method signature for an event handler includes arguments that you would not need in other contexts. Why not structure as follows:
You can then execute
DoSomethingwhenever you like!