c# - WPF 绑定(bind)可见性

标签 c# wpf

我的标签应该在 RadioButton FirstSecond 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/

相关文章:

c# - 发送数据时,为什么 System.Net.Http.StreamContent 将整个流读入内存,忽略给定的缓冲区大小?

c# - 将组合框绑定(bind)到模型/ View 模型

c# - BitmapImage:访问关闭的 StreamSource

wpf - 打开 ContextMenu 时驻留的控件的悬停效果

c# - 在另一个程序集中引用 ResourceDictionary

c# - Content-Disposition 中的 HttpClient 编码错误

c# - 如何将 Nullable<Boolean> 值传递给 CommandParameter?

c# - 在本地计算机上构建的 C# dll 与 TFS 构建服务器之间的区别

c# - 静态只读字段和性能

c# - 我们如何使用 EF 在 ASP.Net MVC 应用程序中创建 3 层架构?