我的标签应该在 RadioButton First
或 Second
IsChecked=true
时可见,在 Third
时折叠或 Fourth
IsChecked=false
。
将按钮的名称传递给转换器并在转换器中决定它应该折叠还是可见,这只是一种方法吗?
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<RadioButton Content="Visible" x:Name="First"></RadioButton>
<RadioButton Content="Visible" x:Name="Second"></RadioButton>
<RadioButton Content="Collapsed" x:Name="Third"/>
<RadioButton Content="Collapsed" x:Name="Fourth"></RadioButton>
</StackPanel>
<Label Content="Test" Grid.Row="1"></Label>
</Grid>
最佳答案
您可以实现 IMultiValueConverter
并使用它将 Visibility
绑定(bind)到多个值。
你可以找到例子 here
关于c# - WPF 绑定(bind)可见性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39854389/