It seems like in the first case, the DataContext
of your Border
is the class that contains the DisplayText
property. But, in the second case the DataContext
of your Border
is the list's item (and it doesn't contain the DisplayText
property).
Try to bind your DataTrigger
to the DisplayText
property of the DataContext
of the ListView
ancestor. Something like:
<Style TargetType="Border" x:Key="changeBorder">
<Setter Property="BorderBrush" Value="Green" />
<Setter Property="BorderThickness" Value="4" />
<Style.Triggers >
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}, Path=DataContext.DisplayText}"
Value="True">
<Setter Property="BorderBrush" Value="Black" />
</DataTrigger>
</Style.Triggers>
</Style>