ToggleSwitch in the WP8

I’m writing WP8 app in the VS2013 and I want to add ToggleSwitch to my mobile app. To achieve that I clicked “Manage NuGet Packages” (the latest version installed) on my project and chose Windows Phone Toolkit. I have the following XAML code:

    xmlns:tool="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
<ToggleSwitch x:Name="toggleSwitch1" Header="ToggleSwitch" 
              OnContent="On" OffContent="Off" 
              Toggled="ToggleSwitch_Toggled"/>

And the errors are: 1) The tag ‘ToggleSwitch’ does not exist in XML namespace ‘http://schemas.microsoft.com/winfx/2006/xaml/presentation’. 2) The name “ToggleSwitch” does not exist in the namespace “http://schemas.microsoft.com/client/2007”.

Also on the WP page the following using statement using Microsoft.Phone.Controls.Toolkit; gets an error: The type or namespace name ‘Toolkit’ does not exist in the namespace ‘Microsoft.Phone.Controls’ (are you missing an assembly reference?)

How can I fix it?



wp7 toggleswitch button color

ToggleSwitch in WP7 has a SwitchBackground color that one can use to change the background of the toggleswitch. I need to change the color of the slider button itself on the toggle switch. I am talkin

How do I use ToggleSwitch with MVVM Light in WP7?

I am trying to use a ToggleSwitch with MVVM Light in a Wp7 app. In the view I have: <toolkit:ToggleSwitch x:Name=toggleAccuracy Content={Binding AccuracyText, Mode=TwoWay} IsChecked={Binding A

WP7 ToggleSwitch to SQL

I’m trying to save the result from a ToggleSwitch (True/False) back to my Azure Database through a WCF. Within the database, the datatype is set to int. Is that correct so far? Then I dont know what f

WP7 swipe gesture on pivot page is changing toggleswitch value

I have a toggleswitch on a pivot page. When the user ‘swipes’ the page, it moves to the next pivot element. This is great functionality. However, when the swipe starts with a ‘tap’ on the toggleswitch

How to customise wp7 toolkit ToggleSwitch

I have the WP7 toolkit and am using the toggle switch. At the moment it displays On or Off. I know you can customise it using the the content template and the sample code supplied with the tookit show

How to detect WP8 at compilation time

I’m developing a cross platform c++ library. I target WP8 among others and I need to detect if the target is WP8 or Desktop Windows. Is there a flag automatically set for WP8 targets? I thought abou

ToggleSwitch Header Color

I have a ToggleSwitch control and the header text is white. The Off and On text is black. How can i change the header text to black? The code is below <toolkit:ToggleSwitch x:Name=Toggle Header=

howto resolve the ToggleSwitch isChecked “bool?” to c# with wp7?

i have a problem with the toggleSwitch from the silverlight toolkit. i need to set the isChecked from a settings class, but i dont know hot to get the bool? type which is required for this. can someon

WP8 + WolfframAPI

I’m trying to use the Wolfram Library on a WP8 app, and am getting this error, as soon as it gets into the function that uses it, before it even starts the function. Type ‘WolframAPI.WAResult’ from a

WP8 AudioPlaybackAgent bug?

I have a problem with playing audio tracks with the AudioPlaybackAgent on devices running WP8. It works perfectly on WP7, but not on WP8. It only works sometimes for WP8, so there is no clear steps on

Answers

If you have installed Nuget Package Properly then below code should run Perfectly.

        xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
         <toolkit:ToggleSwitch x:Name="ToggleSwitch" Header="Toggle Switch" IsChecked="false" Content="Content Goes here" Checked="switch_Checked" Unchecked="switch_Unchecked"/>

You need to use your namespace identifier as a prefix in your element call. Like this

<tool:ToggleSwitch x:Name="toggleSwitch1" Header="ToggleSwitch" 
          OnContent="On" OffContent="Off" 
          Toggled="ToggleSwitch_Toggled"/>

That should fix your problem.