title: WPF Binding not updating Visibility
body: <p>I'm having trouble with the binding to a visibility of a grid.  I've had projects where I've done this before and have tried to replicate the same coding used previously, and I've searched around and added in the bool to visibility converter based off some other articles but still nothing.</p>
  
  <p>All that I am trying to do so far in this project is have a set of options that will be provided to the user.  When they select one option it will either bring up sub-options or just take them to the proper area.  I have the binding set to a bool object and have at times created little message boxes and others just to let me know if the program is reaching everywhere.  I get every messagebox along the way, so it appears to be reaching every piece of code.</p>
  
  <p>Can anyone shed some light on what I am doing wrong or point me in the correct direction?</p>
  
  <p>Converter in Windows.Resources (Edited to show all code in Windows.Resources)</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;Style TargetType="{x:Type Button}"&gt;
          &lt;Setter Property="FontSize" Value="15"/&gt;
          &lt;Setter Property="FontWeight" Value="Bold" /&gt;
          &lt;Setter Property="Height" Value="50" /&gt;
          &lt;Setter Property="Width" Value="100" /&gt;
          &lt;Setter Property="Margin" Value="0,0,0,0" /&gt;
          &lt;Setter Property="HorizontalAlignment" Value="Center" /&gt;
          &lt;Setter Property="VerticalAlignment" Value="Center" /&gt;
      &lt;/Style&gt;
      &lt;BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>Code in the rest of the window</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;Grid x:Name="grid_mainMenu" Visibility="{Binding MainMenuVisibility, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0,0,0,20"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="1*"/&gt;
              &lt;RowDefinition Height="1*"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Button x:Name="button_Items" Content="Items" Grid.Row="0" Click="button_Items_Click"/&gt;
          &lt;Button x:Name="button_Orders" Content="Orders" Grid.Row="1" Click="button_Orders_Click" /&gt;
          &lt;TextBox Text="{Binding StatusMessage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,0" HorizontalAlignment="Left"  VerticalAlignment="Top" Height="100" Width="100"/&gt;
      &lt;/Grid&gt;
      &lt;Grid x:Name="grid_itemMenu" Visibility="{Binding ItemMenuVisibility, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0,0,0,20"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="1*"/&gt;
              &lt;RowDefinition Height="1*"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Label Content="Item Menu" Grid.Row="0" FontSize="20" FontWeight="Bold" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
          &lt;Button Grid.Row="1" x:Name="button_itemMaintenance" Content="Maintenance"/&gt;
          &lt;Button Grid.Row="2" x:Name="button_itemCreation" Content="Create"/&gt;
      &lt;/Grid&gt;
      &lt;DockPanel Height="25" Margin="0,0,0,0" VerticalAlignment="Bottom"&gt;
          &lt;StatusBar DockPanel.Dock="Bottom"&gt;
              &lt;StatusBarItem&gt;
                  &lt;TextBlock Text="{Binding StatusMessage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/&gt;
              &lt;/StatusBarItem&gt;
          &lt;/StatusBar&gt;
      &lt;/DockPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Here is the code in the class</p>
  
  <pre><code>    public bool MainMenuVisibility
      {
          get { return _mainMenuVisibility; }
          set { _mainMenuVisibility = value; RaisePropertyChanged(); }
      }
  
      public bool ItemMenuVisibility
      {
          get { return _itemMenuVisibility; }
          set
          { _itemMenuVisibility = value; RaisePropertyChanged(); }
      }
  
      public bool OrderMenuVisibility
      {
          get { return _orderMenuVisibility; }
          set { _orderMenuVisibility = value;  RaisePropertyChanged(); }
      }
  </code></pre>
  
  <p>Main Constructor</p>
  
  <pre><code>public Menu_View()
      {
          ShowMainMenu();
      }
  </code></pre>
  
  <p>A couple of the controls</p>
  
  <pre><code>public void ShowMainMenu()
      {
          MainMenuVisibility = true;
          HideItemMenu();
          HideOrderMenu();
          StatusMessage = "Showing main menu";
      }
  
      public void HideMainMenu()
      {
          MainMenuVisibility = false;
          StatusMessage = "Hid main menu";
      }
  
      public void ShowItemMenu()
      {
          try
          {
              //Reaches, but never updates
              ItemMenuVisibility = true;
              HideMainMenu();
              HideOrderMenu();
          }
          catch(Exception error)
          {
              //Never shows anything here
              StatusMessage = "Failed to load item menu";
          }
          finally
          {
              //Does not update, but reaches here
              StatusMessage = "Showing item menu";
          }
      }
  </code></pre>
  
  <p>Program starts by showing the main menu, when user clicks a button for Items it is supposed to show the item menu.  The button click calls ShowItemMenu().  I have verified that that does happen and is called in proper order.</p>
  
  <p>I have verified that ShowItemMenu() does work but putting in the constructor instead of ShowMainMenu().  Either one works fine, but neither will cause an update after the initial loading even though they are reached after button presses.</p>
  
  <p>Sorry if I did not include everything I needed.</p>
  
  <p>EDIT:</p>
  
  <p>I believe that I actually had two issues going on simultaneously.  One an improperly configured data converter.  Answer and reference below.</p>
  
  <p>As well as an issue in my window code here:</p>
  
  <pre><code>public MainWindow()
      {
          InitializeComponent();
          menuView = new Menu_View();
          this.DataContext = new Menu_View();
      }
  
      Menu_View menuView;
  </code></pre>
  
  <p>I believe this was part of the issue.  I was creating a menuView of type Menu_View.  On initialize I assigned menuView to a new Menu_View() and then assigned my DataContext to a new Menu_View() instead of menuView.  All commands were updating menuView and I was updating the one assigned to the DataContext.</p>