zoukankan      html  css  js  c++  java
  • WPF错误:必须使“Property”具有非 null 值。

    这个问题一般出如今Triggers中Property指定的类型为Nullable。

    解决的方法就是用DataTrigger取代Trigger, 然后用Binding+Converter转换为详细非Null值。

    比方:
    <Style x:Key="DisableStyle" TargetType="Button">
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding ElementName=ckb1, Path=IsChecked, Converter={StaticResource NullableToBooleanConverter}}" Value="true"></Condition>
                            <Condition Binding="{Binding ElementName=ckb2, Path=IsChecked, Converter={StaticResource NullableToBooleanConverter}}" Value="true"></Condition>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="IsEnabled" Value="False"></Setter>
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>


    NullableToBooleanConverter:
    public object Convert( object value , Type targetType, object parameter, CultureInfo culture )
            {
                Nullable<bool > isCheck = value as Nullable< bool>;
                if (null == isCheck)
                {
                    return false ;
                }
                else
                {
                    return isCheck .Value;
                }
            }
  • 相关阅读:
    字符串转换成整数
    回文字符串判断
    字符串包含
    翻转单词顺序VS左旋转字符串
    穷举子集合
    求S=a+aa+aaa+aaaa+aa...a的值
    数组元素去重
    找最长等差数列的长度
    Git pull and push
    Google 开发console查找元素或方法
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/7044090.html
Copyright © 2011-2022 走看看