我有一行三列的 WPF 网格:
标签1 | 控制1 | 控制2
当两个控件都被隐藏时,我想将Label1
可见性设置为隐藏:
在 XAML 中执行此操作的任何简单方法?
我有一行三列的 WPF 网格:
标签1 | 控制1 | 控制2
当两个控件都被隐藏时,我想将Label1
可见性设置为隐藏:
在 XAML 中执行此操作的任何简单方法?
you can use Multibinding and a MultiConverter on Label1.Visibility to do this job
or you use Style Trigger for your Label1 and set the initial visibility to hidden and use 2 triggers to set the visibility to visible if one of the controls are visible
EDIT
<Label x:Name=Label1>
<Label.Style>
<Style TargetType="Label">
<Setter Property="Visibility" Value="Hidden"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ctl1, Path=Visibility}" Value="Visible">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=ctl2, Path=Visibility}" Value="Visible">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>