I am trying to bind a bool value to checkboxes in a GridViewColumn
, but it doesn't work. I even tried just returning false, but the checkboxes still look enabled. It only works if I type "False" into the xaml.
The binded property is:
public bool HasPermissions
{
get { return this.UserPrivileges == UserPrivileges.FullAccess; }
}
Current value of this.UserPrivileges
is not UserPrivileges.FullAccess
.
Xaml code:
<Window x:Class="EffectsWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Effects Manager"
Width="800"
Height="500"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
<DockPanel VerticalAlignment="Stretch">
<DockPanel.Resources>
<ListView x:Name="EffectsListView"
ItemsSource="{Binding AllEffects}">
<ListView.View>
<GridView>
<GridViewColumn Width="50" Header="Override">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Margin="0"
HorizontalAlignment="Center"
IsEnabled="{Binding HasPermission}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</Window>
EDIT: Current property code:
public bool HasPermissions
{
get { return this.UserPermissions == UserPermissions.FullAccess; }
set { this.RaisePropertyChanged ( "HasPermissions" ); }
}