MultiDataTrigger Binding to Collection and To a property within the collection
I have the following XAML:
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=Errors, Converter={StaticResource ErrorsCountConverter}}">
<Condition.Va开发者_开发百科lue>True</Condition.Value>
</Condition>
<Condition Binding="{Binding Path=Errors[0].HasError}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="Red" />
</MultiDataTrigger>
</Style.Triggers>
Errors is a ObservableCollection<BrokenRule>
. The BrokenRule has a property called HasError. Now, I want to bind to that HasError property but not sure how to reference it in XAML.
There is a relatively unknown forward-slash syntax for accessing a collection's current item. so if you want to bind to the current item of a data source you'd use "{Binding Path=/}"
since you seem to want to automatically increment your Errors collection and have HasError respond accordingly you'd should be able to use something like "{Binding Path=Errors/HasError}"
to get the HasErrors property of the current item in Errors.
Hope that helps!
精彩评论