我正在VS2013中编写VS2013应用程序,我想将ToggleSwitch添加到我的移动应用程序中。为此,我在我的项目上单击了“管理NuGet包”(最新安装的版本),并选择了Windows Phone Toolkit。我有以下XAML代码:
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"/>这些错误是: 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".
同样在WP页面上,以下使用语句using Microsoft.Phone.Controls.Toolkit;获得一个错误:The type or namespace name 'Toolkit' does not exist in the namespace 'Microsoft.Phone.Controls' (are you missing an assembly reference?)
我怎么才能修好它?
发布于 2014-07-16 10:47:52
如果您已经正确地安装了Nuget软件包,那么下面的代码应该运行得很完美。
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"/>发布于 2014-07-16 10:51:41
您需要在元素调用中使用命名空间标识符作为前缀。像这样
<tool:ToggleSwitch x:Name="toggleSwitch1" Header="ToggleSwitch"
OnContent="On" OffContent="Off"
Toggled="ToggleSwitch_Toggled"/>这应该能解决你的问题。
https://stackoverflow.com/questions/24778571
复制相似问题