Home > Silverlight > IPhone (like) switch button in Silverlight

IPhone (like) switch button in Silverlight

On a project I had the intention of using an IPhone-like switch button for setting a confidential flag in the UI. After some research on the internet I haven’t found an usable solution…

I spend some time to design a switch button in XAML, the switch button is based on a classical checkbox control: if the switch button has the 0 value, the control has the unselected state, if the button has the 1 value, the control has the selected state.

A preview:

SL Switch Button ONSL Switch Button OFF

You can change the color in the Generic.xaml by replacing the following XAML with your own brush:

<!--Checked rectangle brush
YOU CAN CHANGE IT IN YOUR PREFERED GRADIENT-->
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0,0"
StartPoint="0,1">
<GradientStop Offset="0"
Color="#D8D8D8" />
<GradientStop Offset="0.5"
Color="#C6C6C6" />
<GradientStop Offset="0.5"
Color="#D8D8D8" />
<GradientStop Offset="1"
Color="White" />
<GradientStop Color="#FFBCC1BE"
Offset="0.5" />
</LinearGradientBrush>
</Rectangle.Fill>

Download source code

  1. adefwebserver
  1. No trackbacks yet.

Leave a comment