0
我是WPF和XAML编程的初学者。而我的英语不太好。对不起!XAML WPF复选框不显示何时更改.ischecked属性
这是我的问题。我想要一个自定义的复选框。它应该只在鼠标结束并且光标应该变为帮助光标时启用。
这工作正常!当我在复选框中单击时,复选框将更改为.ischeckd = true
,并在复选框中显示litte箭头。当我再次点击复选框时,.ischecked
属性更改为false
,但复选框中的小箭头消失了。到现在为止还挺好! 但是,当我设置.ischeckd Value Programaticaly时,它不会更改复选框中的小箭头。因此,该程序的用户认为即使.ischecked属性为false,该复选框也是“活动的”。希望你明白我的问题...... 这里是XAML代码:
</Style>
<Storyboard x:Key="StoryboardCheckBox"/>
<Style x:Key="CheckBoxStyle1" TargetType="{x:Type CheckBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Grid Margin="0,0,42,0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="checkBox">
<DiscreteBooleanKeyFrame KeyTime="0" Value="True"/>
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<CheckBox x:Name="checkBox" Content="Gutschrift" FontSize="13.333" IsEnabled="False" Cursor="Help" Margin="0,0,4.937,0"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="" Margin="78.063,9.723,0,0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
... 一些标贴和按钮和其他的东西
<CheckBox Content="CheckBox" HorizontalAlignment="Left" Height="23" Margin="29,0,0,44" Grid.Row="1" Style="{DynamicResource CheckBoxStyle1}" VerticalAlignment="Bottom" Width="125" Name="CheckBoxGutschrift" IsChecked="False" DataContext="{Binding}" Checked="CheckBoxGutschrift_Checked" Unchecked="CheckBoxGutschrift_Unchecked" ClickMode="Press" IsTabStop="False" />
希望你明白我的问题!非常感谢您的答案,Ruediger
就像一个魅力!非常非常感谢你! – user2006644