c# WPF 动态设置button的IsEnabled属性

XAML:

<DataGridTemplateColumn  Header="类型费用模板" Width="Auto" >
        <DataGridTemplateColumn.CellTemplate>
              <DataTemplate>
                   <StackPanel Orientation="Horizontal">
                       <Label Content="{Binding busi_limit_str}" />
                       <Custom:MetroButton   Content="关联类型模板" Command="{Binding DataContext.ClickReletion_fee_assertacco1,RelativeSource={RelativeSource AncestorType=Custom:MetroDataGrid}}" Width="81" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
                       <Custom:MetroButton   Content="取消关联" IsEnabled="{Binding IsTypeEnable}" Command="{Binding DataContext.DeleteFeeTmplate1,RelativeSource={RelativeSource AncestorType=Custom:MetroDataGrid} }"  Width="81" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
                    </StackPanel>
                </DataTemplate>
         </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

根据busi_limit_str是否为空,来确定取消关联是否可操作。

VM:

astAco.busi_config_str = getDictStr("secu_fee_tmplat_no", SecuFee.secu_code_fee_tmplat_no.ToString());
astAco.busi_limit_str = getDictStr("secu_fee_tmplat_no", SecuFee.secu_type_fee_tmplat_no.ToString());
astAco.IsCodeEnable = !string.IsNullOrWhiteSpace(astAco.busi_config_str);
astAco.IsTypeEnable = !string.IsNullOrWhiteSpace(astAco.busi_limit_str);

遍历每一个对象,对其IsCodeEnable进行赋值。这样就对每一个对象进行动态赋值了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值