I want to build a RowStyle
which changes the Visibility
of the Rows, depending on two conditions (OR).
Per default all Rows should be collapsed an be visible whether a Boolean (in ViewModel) is set to True
OR a value in the DataTable
, bound to the Datagrid
, equals to the current User. So, the current user is, of course, a Property too.
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window},Mode=FindAncestor},Path=DataContext.ColleaguesVisible}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding CreatingUser}" Value="{Binding CurrentStaffMember}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
But at the Value Binding there's the error...
I already searched around, but I couldn't find a solution for this problem.
I hope someone can help me.
Where does 'CreatingUser' sits? in row DataContext(your item), or in ViewModel Behind DataGrid, Or in ViewModel behind Window?
maybe thats your problem?
You can't bind the
Value
property to aDataTrigger
to something because it is not a dependency property.What you could do is to use a converter: