I have DataGrid with multiple DataGridTemplateColumn
. In one of these columns, I have a button that I want to show when the user select the row and also If CodeFonc
is equal to 1. (CodeFonc is not part of DataGrid/SelectedItem)
ViewModel:
private int _codeFonc;
public int CodeFonc
{
get { return _codeFonc; }
set
{
_codeFonc = value;
NotifyOfPropertyChange("CodeFonc");
}
}
XAML:
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}, Path=IsSelected}" Value="True"/>
<Condition Binding="{Binding Path=CodeFonc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Value="1" />
</MultiDataTrigger.Conditions>
<Setter Property="Button.Visibility" Value="Visible" />
</MultiDataTrigger>
I'm getting CodeFonc from another window but I'm 100% sure that its value is 1 because I confirmed while debugging.
Most importantly:
If I ever replace the CodeFonc
with anything from the DataGrid (SelectedItem) itself, the button will show fine. So my guess is that because the XAML above is inside the DataGrid, its limiting it somehow?