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;
                }
            }
  • 相关阅读:
    Max_connect_errors – MySQL性能参数详解
    python qt
    Topo图
    ECSHOP报错误Deprecated: preg_replace(): The /e modifier is depr
    Socat
    Tomcat多次部署
    Android进程守护
    mysql将字符转换成数字
    Oracle sql查询
    ZOJ 题目2859 Matrix Searching(二维RMQ)
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/7044090.html
Copyright © 2011-2022 走看看