My main window view:
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
</Window.Resources>
<Grid x:Name="TopGrid">
<Rectangle x:Name="TopPanel" Grid.ZIndex="3"
Fill="LightBlue" Opacity="0.3"
Visibility="{Binding IsContentBlocked, Mode=TwoWay, Converter={StaticResource BoolToVisibility}}" />
<Grid Name="main" DataContext="{StaticResource mainViewModel}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- Here my controls: stackpanel, buttons, groupboxes, etc. -->
</Grid>
</Grid>
View model:
private bool isContentBlocked = false;
public bool IsContentBlocked
{
get
{
return this.isContentBlocked;
}
set
{
if (this.isContentBlocked == value)
{
return;
}
this.isContentBlocked = value;
OnPropertyChanged("IsContentBlocked");
}
}
Initially when I launch WPF app, top panel should be hidden so all content shoudl be enabled, user should be able to play with them but for some reason, the top panel is not being hidden, it is shown, so all content cannot be accessed. I use a rectangle to make content to figure as blocked.
What am I doing wrong?
My view model is implementing INotifyPropertyChanged correctly.