I am using MVVM pattern and I have one DataGrid with a column which shows some picture if two boolean values are set to true. One value is in DataView (DtView) which is bind to generate rows and there is no problem with binding, but the other value is public property from ViewModel (same as where DtView is) and here is problem. I don't know how to solve this.
Here is my code:
<DataGrid ItemsSource="{Binding Path=DtView}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Status">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="../Images/a.png" Width="18" Height="18">
<Image.Style>
<Style TargetType="Image">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding 'column from DtView'}" Value="True" />
<Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=Column from other DataView}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Visible" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
If somebody can help me, than I would be really happy, because this is frustrating and I don't know how to fix this code.
Try
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding 'column from DtView'}" Value="True" />
<Condition Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGrid}},
Path=DataContext.OtherDtView.Column from other DataView}" Value="True" />
</MultiDataTrigger.Conditions>