Skip to content Skip to sidebar Skip to footer

Creating Own Toggle Button In Wp8?

I need to port an Android app which has a widget to WP8. For this I need to create my own toggle button (user control). So I just created a subclass of Button called MyToggleButton

Solution 1:

Here is a simplified "Toggle" button using images. based on CheckBox

<StyleTargetType="{x:Type CheckBox}" ><SetterProperty="Template" ><Setter.Value><ControlTemplateTargetType="{x:Type CheckBox}"><Grid><ContentPresenterx:Name="Part_Content" /><ImageName="image"Source="/WpfApplication4;component/Images/avatar63.jpg" /></Grid><ControlTemplate.Triggers><TriggerProperty="IsChecked"Value="true" ><SetterTargetName="image"Property="Source"Value="/WpfApplication4;component/Images/imagesCA7JZMMY.jpg"/></Trigger><TriggerProperty="IsChecked"Value="False" ><SetterTargetName="image"Property="Source"Value="/WpfApplication4;component/Images/avatar63.jpg"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style>

Solution 2:

You should probably not make a custom toggle in the first case. Porting an application from Android doesn't mean you also have to port its graphics. They simply don't share the same design language. You should probably stick to the native WP8 toggle.

However, if you really want to create a custom checkbox/toggle, you should check this. This was made for WP7, but it also applies to WP8.

Post a Comment for "Creating Own Toggle Button In Wp8?"