我试图通过样式来做到这一点。但是所有样本都与验证相关联 - 如何绑定到"编辑模式"
<RibbonButton.Style>
<Style TargetType="RibbonButton">
<Setter Property="IsEnabled" Value="False"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="Binding Path=(Validation.???EDIT MODE)"
</MultiDataTrigger.Conditions>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</RibbonButton.Style>
答案 0 :(得分:2)
如果通过编辑模式,则表示TextBox
具有焦点,您可以使用IsKeyboardFocusWithin
属性,并且当IsEnabled=True
的此属性为false时触发TextBox
<StackPanel>
<TextBox x:Name="textBox1"/>
<TextBox x:Name="textBox2"/>
<RadioButton>
<RadioButton.Style>
<Style TargetType="{x:Type RadioButton}">
<Setter Property="IsEnabled" Value="False"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=textBox1, Path=IsKeyboardFocusWithin}" Value="False"/>
<Condition Binding="{Binding ElementName=textBox2, Path=IsKeyboardFocusWithin}" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled" Value="True"/>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</RadioButton.Style>
</RadioButton>
</StackPanel>
1}} ES
IsHitTestVisible