如何将 2 个值传递给我的 ValueConverters 类?
我的 Xaml 上有这个,我正在传递分配给更改网格单元颜色的值。但我想同时检查输入的变量值,以便我可以根据该值进行更改。如何传递 2 个值,以便我可以在 iconverter 类上设置条件。
<DataGridTextColumn Binding="{Binding Allocated}" Header="Allocated" >
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Background" Value="{Binding Allocated, Converter={StaticResource converter}}"/>
</Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn>
我的转换器类:
对象 IValueConverter.Convert(对象值,类型 targetType,对象参数,System.Globalization.CultureInfo 文化){
string input = value.ToString();
switch (input)
{
case "99":
return Brushes.Green;
case "96":
return Brushes.Green;
case "91":
default:
return DependencyProperty.UnsetValue;
}
}
块引用
提前致谢!
I have got this on my Xaml , I am passing value allocated to change gridcell colour. But I want to check also at same time Entered variable value so I can change according to that.How can I pass 2 values so I can have conditions on my iconverter class.
<DataGridTextColumn Binding="{Binding Allocated}" Header="Allocated" >
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Background" Value="{Binding Allocated, Converter={StaticResource converter}}"/>
</Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn>
my Converter class:
object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture){
string input = value.ToString();
switch (input)
{
case "99":
return Brushes.Green;
case "96":
return Brushes.Green;
case "91":
default:
return DependencyProperty.UnsetValue;
}
}
Blockquote
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
MultiBinding
:并使用您的转换工具
IMultiValueConverter
:Use
MultiBinding
:and ake your convet implement
IMultiValueConverter
: