是否可以选择ListBox项的特定文本

时间:2015-04-27 11:01:59

标签: c# wpf

查看声明:

<ListBox x:Name="LboxItems" ItemsSource="{Binding Items}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Name="itemTemplate"  Text="{Binding Info}" Foreground="{Binding Foreground}"></TextBlock>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

代码背后:

for (int i = 0; i < LboxItems.Items.Count; i++)
{

    var item= LboxItems.Items[i] as TestItem;

    if (monitorItem != null)
    {
        var index = item.Info.IndexOf(textToFind);
        //TODO textToFind has been found therefore highlight it 
    }
}

是否可以在WPF中高亮显示ListBox中的文本片段?

0 个答案:

没有答案