I ran in to the unique situation today where I needed to bind the Visible
property of a button in a DataGridRow
to be based on both a property of the bound object and of the model backing it.
XAML:
<t:DataGrid ItemsSource="{Binding Items}">
<t:DataGrid.Columns>
<t:DataGridTemplateColumn>
<t:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Visibility="IsEditable OR IsAdmin"/>
</DataTemplate>
</t:DataGridTemplateColumn.CellTemplate>
</t:DataGridTemplateColumn>
</t:DataGrid.Columns>
</t:DataGrid>
Model:
class TheModel
{
public ObservableCollection<Whatever> Items { get; set; }
public bool IsAdmin { get; set; }
}
Class:
class Whatever
{
public bool IsEditable { get; set; }
}
This stumped me. The only concept that I could think might work would be somehow passing the bound object and either the entire model or just the IsAdmin
property to a static method on a converter or something. Any ideas?