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

Advertisements
  1. adefwebserver
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: