将Visibility枚举值作为ConverterParameter传递

时间:2015-03-05 16:35:36

标签: wpf xaml

我想知道如何将System.Windows.Visibility Enum作为转换器的参数传递:

<Bdl:BdlRoundButton Name="BtAddUser" Grid.Row="1" Grid.Column="2" Color="Orange" Image="Create" Command="{StaticResource GetSequence}" Margin="5,0,0,0"
                            Visibility="{Binding Converter={StaticResource StringNotNullToVisibilityConverter}, ConverterParameter={System.Windows.Visibility.Hidden}}"/>

1 个答案:

答案 0 :(得分:0)

如@dkozl所述,您可以使用x:Static Markup Extension

引用以兼容公共语言规范(CLS)的方式定义的任何静态按值代码实体。引用的静态属性可用于提供XAML中属性的值。

所以您的代码应如下所示:

<Bdl:BdlRoundButton Name="BtAddUser" Grid.Row="1" Grid.Column="2" Color="Orange" 
                    Image="Create" Margin="5,0,0,0"
                    Command="{StaticResource GetSequence}" 
                    Visibility="{Binding Converter={StaticResource StringNotNullToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>