当所有菜单项都被隐藏时,我想在我的上下文菜单中隐藏分隔符。如果两个菜单项中的至少一个可见,则分隔符也必须可见。
我试过了:
<Separator>
<Separator.Style>
<Style TargetType="Separator">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=Visibility, ElementName=Item1}" Value="Collapsed" />
<Condition Binding="{Binding Path=Visibility, ElementName=Item2}" Value="Collapsed" />
</MultiDataTrigger.Conditions>
<Setter Property="Separator.Visibility" Value="Collapsed" />
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=Visibility, ElementName=Item1}" Value="Visible" />
<Condition Binding="{Binding Path=Visibility, ElementName=Item2}" Value="Visible" />
</MultiDataTrigger.Conditions>
<Setter Property="Separator.Visibility" Value="Visible" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Separator.Style>
</Separator>
<MenuItem x:Name="Item1" Header="Item1" Visibility="{Binding Item1Visibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<MenuItem x:Name="Item2" Header="Item2" Visibility="{Binding Item2Visibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
但是分隔符始终是隐藏的。我的代码有什么问题?