如何使用Xaml在Devxpress Gridcontrol中提供if和else格式化程序?
我正在使用Xaml开发一个使用Devexpress Gridcontrol的应用程序。在单元格模板中,我有一个文本块,如果绑定中的值为“0”,我想在其中显示“打开”,如果为“0”,则显示“关闭”。是否可以使用如何使用Xaml在Devxpress Gridcontrol中提供if和else格式化程序?,xaml,devexpress,gridcontrol,Xaml,Devexpress,Gridcontrol,我正在使用Xaml开发一个使用Devexpress Gridcontrol的应用程序。在单元格模板中,我有一个文本块,如果绑定中的值为“0”,我想在其中显示“打开”,如果为“0”,则显示“关闭”。是否可以使用FormatterString即使用FormatStringConverter?希望这有帮助。:) xmlns:i=”http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei=”http://schemas.mi
FormatterString
即使用FormatStringConverter
?希望这有帮助。:)
xmlns:i=”http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei=”http://schemas.microsoft.com/expression/2010/interactions"
所以如果它为0,您希望它显示打开和关闭?或者你的问题中有错别字?还有,你是说WPF吗,SL?如果它返回null,您可以在绑定基中指定一个TargetNullValue
,或者如果它是0,您可以使用DataTrigger
&changepropertyaaction
,甚至不使用转换器。很抱歉,我的问题是错误的。实际上,如果绑定中的值为“0”,则应该类似于“打开”,如果绑定中的值为“1”,则应该类似于“关闭”。没问题,很高兴您得到了修复:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
<TextBlock Text="{Binding Value}">
<i:Interaction.Triggers>
<ei:DataTrigger Value="0" Binding="{Binding Text, ElementName=Self}">
<im:ChangePropertyAction PropertyName="Text"
Value="Open"/>
</ei:DataTrigger>
<ei:DataTrigger Value="1" Binding="{Binding Text, ElementName=Self}">
<im:ChangePropertyAction PropertyName="Text"
Value="Close"/>
</ei:DataTrigger>
</i:Interaction.Triggers>
</TextBlock>