我想用ToggleSwitch
控制的WPF Spark project结合包含自定义控件
一个UserControl所以我创建了一个UserControl
含有ToggleSwitch
控制,并将其配置(颜色,大小等)。
<UserControl x:Class="WpfControls.ToggleSwitch.MyToggleSwitchControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toggleSwitch="clr-namespace:WpfControls.ToggleSwitch"
d:DesignHeight="300"
d:DesignWidth="300"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WpfControls;component/ToggleSwitch/ToggleSwitch.Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<toggleSwitch:ToggleSwitch x:Name="Toggle"
Width="54"
Height="21"
Margin="0"
Background="Black"
BorderThickness="2"
CheckedForeground="White"
CheckedText="Yes"
CheckedToolTip=""
CornerRadius="10"
FontFamily="Tahoma"
FontSize="10"
FontWeight="Normal"
IsCheckedLeft="False"
Padding="0"
ThumbBorderThickness="2"
ThumbCornerRadius="21"
ThumbGlowColor="Gray"
ThumbShineCornerRadius="20,20,0,0"
ThumbWidth="35"
UncheckedForeground="Black"
UncheckedText="No"
UncheckedToolTip="No">
</toggleSwitch:ToggleSwitch>
</Grid>
</UserControl>
的ToggleSwitch
是CustomControl
其覆盖标准WPF ToggleButton
。
现在我想在我的XAML
中使用ToggleButton
属性IsChecked
进行绑定。
<toggleSwitch:MyToggleSwitchControl IsChecked="{Binding IsChecked}" />
我该如何做到这一点?
我得到一个警告,这DP隐藏继承成员切换按钮 –
的器isChecked我想我需要访问ToggleSwitch控件我的用户里面莫名其妙。你能帮助我吗? –
您可以使用'新'关键词来避免此警告,或者为此DependencyProperty选择除'IsChecked'之外的其他名称。 – Rafal