highlight the item with same text if already in itemscontrol collection

harry777 61 Reputation points
2020-08-19T13:44:01.3+00:00

18829-xxx.txtHi,

I have two textboxes where user enters prefix and suffix to be appended in already existing itemscontrol of checkboxes. I want the functionality if the name already exists s.t. prefixText+any item+ suffixText then make the existing item red and bold.

18739-image.png

Attached file has XAML and ViewModel. (Do I need MultiBinding?)

Edit: attached text file

Many thanks,
Harry

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,696 questions
0 comments No comments
{count} votes

Accepted answer
  1. Peter Fleischer (former MVP) 19,306 Reputation points
    2020-08-19T14:11:08.27+00:00

    Hi Harry,
    check value of DataTrigger to "True" and return true/fasle from Converter.

                    <DataTrigger Value="True">  
                      <DataTrigger.Binding>  
                        <MultiBinding Converter="{StaticResource conv}">  
                          <Binding RelativeSource="{RelativeSource Self}" Path="Content"/>  
                          <Binding Path="Text" ElementName="prefixTB"/>  
                          <Binding Path="Text" ElementName="suffixTB"/>  
                        </MultiBinding>  
                      </DataTrigger.Binding>  
                      <Setter Property="Foreground" Value="Red"/>  
                      <Setter Property="FontWeight" Value="DemiBold"/>  
                    </DataTrigger>  
    

    Converter:

    18853-x.png

    Or shorter:

    18775-x.png


0 additional answers

Sort by: Most helpful