列表框系统 [英] listbox ltem
本文介绍了列表框系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个绑定到Ilist的列表框
I've got a listbox which i'm binding to a Ilist
如果文本包含字符串(例如"Log错误"),我想使列表项目的背景为红色.
I want to make the background of the list item red if the text contains a string for example "Error with Log".
我该怎么做?
推荐答案
<ListBox Margin="12" Name="listBox1">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding }" Value="Error">
<Setter Property="ListBoxItem.Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
这篇关于列表框系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文