I have a class like:
class EditorViewModel
{
public ObservableCollection<Effect> AllEffects;
public bool HasPermissions;
}
But the problem is, when I am trying to bind AllEffects
to ListView
, then I can't bind anything to HasPermissions
because the binding scope is limited to AllEffects
, not EditorViewModel
.
I tried this but it doesn't work:
<ListView ItemsSource="{Binding EditorViewModel}">
...
<GridViewColumn Width="Auto" Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding AllEffects.Name}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="Auto" Header="Type">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding AllEffects.Type}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
If I set the ItemsSource
to EditorViewModel
and get rid of AllEffects
, it works. But then I don't know how to access HasPermissions
through binding:
<GridViewColumn Width="50" Header="Override">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Margin="0"
HorizontalAlignment="Center"
IsEnabled="{Binding HasPermission}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>