In this post I will discuss the Toggle Switch Button. This comes as part of the Silverlight toolkit for Windows Phone 7 and you can get it from
here
![ToggleSwch1.gif]()
To work with the Toggle Switch, you need to add a namespace
xmlns:tool="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
You can use a ToggleSwitch as below,
<tool:ToggleSwitch
x:Name="tglSwitch"
Header="wifi"
Checked="tglSwitch_Checked"
Unchecked="tglSwitch_Unchecked"/>
You can set the Header and Content of the Toggleswitch. If you want you can very
much templateaize the Header and Content.
There are four events attached to the Toggle Switch.
![ToggleSwch2.gif]()
You can handle the events as below,
void
tglSwitch_Click(object sender,
RoutedEventArgs e)
{
MessageBox.Show("Its
Clicked");
}
void tglSwitch_Indeterminate(object
sender, RoutedEventArgs e)
{
MessageBox.Show("Its
intermidiate");
}
private void
tglSwitch_Checked(object sender,
RoutedEventArgs e)
{
tglSwitch.Content = "on";
}
private void
tglSwitch_Unchecked(object sender,
RoutedEventArgs e)
{
tglSwitch.Content = "off";
}
In this way you can work with ToggleSwitch . I hope this post is useful. Thanks
for reading.