如果绑定的值为 false 或 null,我希望有一个按钮变为禁用状态。以下是我尝试过的方法:
我有一个案例,其中SearchItem.WFBatchFolderStatus可能为null(由于业务需求)。如果SearchItem.WFBatchFolderStatus为null,则我希望禁用该按钮。当SearchItem.WFBatchFolderStatus为null时,转换器不会触发。如果SearchItem.WFBatchFolderStatus不是null,则转换器会触发。转换器只返回false值,如果其它情况则返回值。但是转换器从来没有收到过null的值。当SearchItem.WFBatchFolderStatus为null时,按钮是启用的(这不是我想要的结果)。如果我删除TargetValue和/或Converter,则在SearchItem.WFBatchFolderStatus为null时,按钮仍然是启用状态。
<Button Content="Open" IsEnabled="{Binding SearchItem.WFBatchFolderStatus.UserCanOpen, Mode=OneWay, TargetNullValue=false, Converter={StaticResource booleanPassThru}}" />
我有一个案例,其中SearchItem.WFBatchFolderStatus可能为null(由于业务需求)。如果SearchItem.WFBatchFolderStatus为null,则我希望禁用该按钮。当SearchItem.WFBatchFolderStatus为null时,转换器不会触发。如果SearchItem.WFBatchFolderStatus不是null,则转换器会触发。转换器只返回false值,如果其它情况则返回值。但是转换器从来没有收到过null的值。当SearchItem.WFBatchFolderStatus为null时,按钮是启用的(这不是我想要的结果)。如果我删除TargetValue和/或Converter,则在SearchItem.WFBatchFolderStatus为null时,按钮仍然是启用状态。