Tool Bars Get stuck behind Avalon Dock - wpf

Im new to WPF and started using Avalon Dock. I have problem with Toolbar. When i drag toolbar in toolbar tray Tray gets expanded down and stuck behind Avalon Dock container.. How do i make it to re-size Automatically down so that Tool bars wont stuck behind?? Here is my XAML.. Thanks:)
<Window x:Class="PSWPF0._001.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonDock="http://avalondock.codeplex.com"
Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="381" d:DesignWidth="754" SizeToContent="WidthAndHeight">
<Grid DataContext="{Binding}" AllowDrop="True" ClipToBounds="True" IsItemsHost="False">
<DockPanel HorizontalAlignment="Stretch" Margin="2,0,0,0" Name="dockPanel1" VerticalAlignment="Stretch" />
<Menu Height="22" HorizontalAlignment="Stretch" Name="menu1" VerticalAlignment="Top" Margin="2,0,-2,0" DockPanel.Dock="Top">
<MenuItem Header="File">
<MenuItem Header="New" Click="MenuItem_Click_4">
<MenuItem Header="Project" />
<MenuItem Header="C Source File" />
<MenuItem Header="Text File" />
</MenuItem>
<MenuItem Header="Open" Click="MenuItem_Click_5"/>
<MenuItem Header="Save" />
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Header="Undo" />
<MenuItem Header="Redo" />
<Separator />
<MenuItem Header="Copy" />
<MenuItem Header="Cut" />
<MenuItem Header="Paste" />
<MenuItem Header="Delete" />
<Separator />
<MenuItem Header="Find" />
</MenuItem>
<MenuItem Header="View" Click="MenuItem_Click_1">
<MenuItem Header="Project Dashboard"/>
<MenuItem Header="Project Explorer" />
</MenuItem>
<MenuItem Header="Help" Click="MenuItem_Click">
<MenuItem Header="About" Click="MenuItem_Click_3"/>
<MenuItem Command="ApplicationCommands.Help" Header="Help Content" />
</MenuItem>
</Menu>
<ToolBarTray DockPanel.Dock="Top" Background="LightGray" VerticalAlignment="Top" Margin="2,23,-2,0">
<ToolBar Band="1" BandIndex="1">
<Button>New</Button>
<Button>Open</Button>
<Button>Exit</Button>
</ToolBar>
<ToolBar BandIndex="2" Band="2">
<Button>Undo</Button>
<Button>Redo</Button>
</ToolBar>
<ToolBar Band="2" BandIndex="2">
<Button>Paint</Button>
<Button>Spaell</Button>
<Separator />
<Button>Cut</Button>
<Button>Copy</Button>
<Button>Paste</Button>
<Separator />
<Button>Find</Button>
<Button>Replace</Button>
</ToolBar>
</ToolBarTray>
<avalonDock:DockingManager x:Name="dockingManager" Margin="0,52,0,28" VerticalAlignment="Stretch" DockPanel.Dock="Top" Grid.Column="0" AllowMixedOrientation="True" IsManipulationEnabled="False" UseLayoutRounding="True">
<avalonDock:LayoutRoot>
<avalonDock:LayoutPanel Orientation="Vertical">
<avalonDock:LayoutDocumentPaneGroup DockMinHeight="70">
<avalonDock:LayoutDocumentPane>
<avalonDock:LayoutDocument Title="Doc1">
<TextBox/>
</avalonDock:LayoutDocument>
<avalonDock:LayoutDocument Title="Doc2">
<TextBox/>
</avalonDock:LayoutDocument>
</avalonDock:LayoutDocumentPane>
<avalonDock:LayoutDocumentPane >
</avalonDock:LayoutDocumentPane>
</avalonDock:LayoutDocumentPaneGroup>
<avalonDock:LayoutAnchorablePaneGroup IsMaximized="True" DockMinHeight="70" DockHeight="250">
<avalonDock:LayoutAnchorablePane>
<avalonDock:LayoutAnchorable Title="Output">
<RichTextBox/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="Error List">
<TextBox/>
</avalonDock:LayoutAnchorable>
</avalonDock:LayoutAnchorablePane>
</avalonDock:LayoutAnchorablePaneGroup>
</avalonDock:LayoutPanel>
<avalonDock:LayoutRoot.RightSide>
<avalonDock:LayoutAnchorSide>
<avalonDock:LayoutAnchorGroup>
<avalonDock:LayoutAnchorable Title="Properties" AutoHideMinWidth="200">
<RichTextBox/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="Project Explorer" AutoHideMinWidth="200">
<RichTextBox/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="File Explorer" AutoHideMinWidth="200">
<RichTextBox/>
</avalonDock:LayoutAnchorable>
</avalonDock:LayoutAnchorGroup>
</avalonDock:LayoutAnchorSide>
</avalonDock:LayoutRoot.RightSide>
<avalonDock:LayoutRoot.LeftSide>
<avalonDock:LayoutAnchorSide>
<avalonDock:LayoutAnchorGroup>
<avalonDock:LayoutAnchorable Title="Project Dashboard" AutoHideMinWidth="200">
<RichTextBox/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="Hardware Toolbox" IsMaximized="True" CanAutoHide="True" IsActive="True" AutoHideMinWidth="200">
<ListBox/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="Logic Building Blocks" AutoHideMinWidth="200">
<RichTextBox/>
</avalonDock:LayoutAnchorable>
</avalonDock:LayoutAnchorGroup>
</avalonDock:LayoutAnchorSide>
</avalonDock:LayoutRoot.LeftSide>
</avalonDock:LayoutRoot>
</avalonDock:DockingManager>
<StatusBar Height="22" HorizontalAlignment="Stretch" Margin="2,322,0,0" Name="statusBar1" VerticalAlignment="Bottom" DockPanel.Dock="Bottom"/>
</Grid>

I'd suggest to use a dynamic layout like this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>//<-- for menu
<RowDefinition Height="Auto"/>//<-- for toolbar
<RowDefinition Height="*"/>//<-- for docking manager
<RowDefinition Height="Auto"/>//<-- for status bar
</Grid.RowDefinitions>
</Grid>
Always use Auto or Start grid lengths for dynamic layout arrangements of children controls,
Ado

I know this is old but it took me a while to figure this out too (AD 2.0 on WPF with .NET 4.5) so I'll post for others who might be using this as a source. The answer from adospace works. However, you'll have to alter your code as well.
Eliminate the top margin from the DockingManager, unless you have another need for it. My layout looked so weird until I realized I still had a top margin set before using the grid's RowDefinitions. Also, remove the DockPanel.Dock="Top" from your menu unless you've got something else going on there. I don't have VerticalAlignment set either.
Here's what I've got that works just fine, including with the multiple bands. Using one of the AD test apps, it already has that root grid (gdlayoutRoot), so you can use that one.
<Grid Name="gdlayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Menu IsMainMenu="True" Name="menuMain" Grid.Row="0">
<MenuItem Header="_File" Name="File">
<MenuItem Header="_New" Name="New" />
</MenuItem>
<MenuItem Header="_Edit" Name="Edit" />
<MenuItem Header="_Document" Name="Document">
<MenuItem Header="Import From _XML">
<MenuItem Header="Entity" Name="ImportFromXML" Click="ImportFromXML_Click" />
</MenuItem>
</MenuItem>
</Menu>
<ToolBarTray Grid.Row="1">
<ToolBar Band="0" BandIndex="0">
<Button Content="Stuff"/>
</ToolBar>
</ToolBarTray>
<ad:DockingManager x:Name="dockingManager" Grid.Row="3">

Related

Set up a footer that stays in the footer area when resize WPF application

I am struggling to set up a footer in a WPF application. I want my footer to be a simple text and nothing more and I want it to stay still when resizing the page. The page contains a menu on in the top, a button, that is put into a canvas because I don't want it to change its size. I also have a textBox that is in a grid and I want it to be resized with the page. Under the textBox I want to setup the footer (I set it up with a label). Can anybody tell me how can I achieve this ? I tried everything ..
Here is the main part of my .XAML file:
<Grid>
<Menu>
<MenuItem Header="_File">
<MenuItem Header="_Exit" Command="{Binding x}"/>
</MenuItem>
<MenuItem Header="_View">
<MenuItem Header="Logs" Comm`enter code here`and="{Binding y}" />
</MenuItem>
</Menu>
<Canvas Margin="0,0,-0.4,432.6">
<Button Command="{Binding z}" Name="Button" Canvas.Top="22" Width="122" Height="24" Canvas.Left="10">Download Images</Button>
</Canvas>
<Canvas Margin="0,0,-0.4,432.6">
<Label HorizontalAlignment="Left" Width="108" Canvas.Left="10" Height="25" Canvas.Top="47">Status</Label>
</Canvas>
<TextBox Name="MessageDisplay" Text="{Binding q, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay,IsAsync=True}" Margin="10,73,10.6,44.6"/>
<Label Margin="0,475,-0.4,-0.4">Footer !!!</Label>
</Grid>
This is how it looks when I run the app:
Before any resize
and this is what happens after I maximize the page :
maximized
You should be making use of RowDefinitions for your Grid to do this reliably. Don't set canvas postions and margins to specific areas or your resizing will never look right. Margin is a great tool, but it should be set in the scope of the area the control is in within the layout
Specify your row definitions and their height. Here's an example using your code. Rows start at index 0. Take this example and look up some more information about specifying grid row and column layouts in WPF. This should get you started on the right path though.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Menu>
<MenuItem Header="_File">
<MenuItem Header="_Exit" Command="{Binding x}"/>
</MenuItem>
<MenuItem Header="_View">
<MenuItem Header="Logs" />
</MenuItem>
</Menu>
<Canvas Grid.Row="1">
<Button Command="{Binding z}" Name="Button" Margin="5" Width="122" Height="24" >Download Images</Button>
</Canvas>
<Canvas Grid.Row="2">
<Label HorizontalAlignment="Left" Width="108" Height="25" >Status</Label>
</Canvas>
<TextBox Grid.Row="3" Name="MessageDisplay" Text="{Binding q, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay,IsAsync=True}" Margin="5"/>
<Label Grid.Row="4" >Footer !!!</Label>
</Grid>

Create custom menu with a button wpf

This is my custom title bar:
That three dot button is a button control. I want to create a menu like this (drew by paint!):
But I don't have any idea. I know there is a "Menu" control but I couldn't use it as I wanted.
"More" button code:
<Button x:Name="More" Grid.Column="1" Style="{DynamicResource TitleBarButton}" IsTabStop="False" Focusable="False">
<Button.Background>
<ImageBrush ImageSource="icons/More.png"/>
</Button.Background>
</Button>
You may replace the Button with a ToggleButton and use a Popup that you bind to the ToggleButton's IsChecked property:
<ToggleButton x:Name="More" Grid.Column="1" Style="{DynamicResource TitleBarButton}" IsTabStop="False" Focusable="False">
<ToggleButton.Background>
<ImageBrush ImageSource="icons/More.png"/>
</ToggleButton.Background>
</ToggleButton>
<Popup IsOpen="{Binding IsChecked, ElementName=More}"
PlacementTarget="{Binding ElementName=More}"
Placement="Bottom">
<StackPanel Width="100" Background="Yellow">
<TextBlock Text="Check For Updates" />
<Grid Background="DarkGray" Height="3" />
<TextBlock Text="Do something else" />
</StackPanel>
</Popup>
You may of course replace the contents of the Popup with whatever you want.
enter image description here
You may need setup menu items to act as buttons
(more WPF button feature int this book)
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Green">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.0*" />
<ColumnDefinition Width="40" />
<ColumnDefinition Width="40" />
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" >
<Menu Height="40" Width="40" Background="Green" >
<MenuItem >
<!-- MENU HEADER -->
<MenuItem.Header>
<Border>
<Image Source="/WpfMenuButton;component/Images/DotsImg.PNG" />
</Border>
</MenuItem.Header>
<!-- MENU ITEM UPDATE -->
<MenuItem Click="CheckUpdate_Click" Background="Chocolate">
<MenuItem.Header>
<TextBlock Text="Check for update" VerticalAlignment="Center" HorizontalAlignment="Center"
Height="30" Width="100" />
</MenuItem.Header>
</MenuItem>
<!-- MENU ITEM WIFI -->
<MenuItem Click="DoSomethingElse_Click" Background="LightGreen">
<MenuItem.Header>
<TextBlock Text="Do something else" VerticalAlignment="Center"
HorizontalAlignment="Center" Height="30" Width="140" />
</MenuItem.Header>
</MenuItem>
<!-- MENU ITEM ABOUT -->
<MenuItem Click="MenuAbout_Click" Background= "LightBlue">
<MenuItem.Header>
<TextBlock Text="About" VerticalAlignment="Center" HorizontalAlignment="Center"
Height="30" Width="140" />
</MenuItem.Header>
</MenuItem>
</MenuItem>
</Menu>
</Grid>
<Grid Grid.Column="2" >
<Button Content="-" Foreground="White" FontSize="28" Background="Green"/>
</Grid>
<Grid Grid.Column="3" >
<Button Content="X" Foreground="White" FontSize="28" Background="Green"/>
</Grid>
</Grid>
</Grid>

How can I get WPF menus to align like the old win forms menu?

I have a WPF app that I am working on. Everything is very simple at the moment as I've not implemented any of the "meat" yet. One of the things that is bothering some of the users with the prototype is that the menu drops down "backwards" from how it used to in win forms.
What I'm looking to have is the left edge of the menu box line up with the left edge of the word "File" in the parent menu. I've been doing some searching but I don't think I'm hitting the right keywords. I'm not sure if it makes any difference but I'm also using the MVVMLight library by Galasoft.
My question is how do I get the left edge of the menu to line up with the left edge of the "File" text? Thanks ahead of time!
<Menu Grid.Row="0" Grid.Column="0">
<MenuItem Header="_File" >
<MenuItem Header="EnableWatcher" IsCheckable="True" IsChecked="{Binding WatcherEnabled}" />
<Separator />
<MenuItem Header="_Exit" />
</MenuItem>
</Menu>
EDIT: Here is all of the code in the xaml file.
<Window x:Class="DonkeySuite.Watcher.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ViewModel="clr-namespace:DonkeySuite.Watcher.ViewModel"
Title="MainWindow" Height="350" Width="525" Icon="/DonkeySuite.Watcher;component/BlueFolder.ico">
<Window.DataContext>
<ViewModel:MainViewModel />
</Window.DataContext>
<!--<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<Command:EventToCommand Command="{Binding SaveSettings}"/>
</i:EventTrigger>
</i:Interaction.Triggers>-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Menu Grid.Row="0" Grid.Column="0">
<MenuItem Header="_File" >
<MenuItem Header="EnableWatcher" IsCheckable="True" IsChecked="{Binding WatcherEnabled}" />
<Separator />
<MenuItem Header="_Exit" />
</MenuItem>
</Menu>
<Grid Grid.Column="0" Grid.Row="1">
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center">Directory:</TextBlock>
<TextBox Grid.Column="1" Text="{Binding WatchDirectory, Mode=TwoWay}" VerticalAlignment="Center"></TextBox>
<Button Grid.Column="2" Content="Browse" Command="{Binding BrowseForDirectory}" Height="24" Margin="5, 0, 15, 0">
</Button>
</Grid>
</Grid>
I finally figured it out. I found a link off Microsoft that resolved my issue. Apparently this was happeneing because I have a Wacom tablet on my computer. It has absolutely nothing to do with WPF.
http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/menus-are-being-right-aligned/cb94ff1e-5c3f-4535-944a-ae5632149a0d
In case the link ends up going away here's the details in a nut-shell.
Press the Windows key + R to bring up the Run dialog box. In the Open
line, copy/paste the following line of text.
shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E}
Press OK.
This will start the Tablet PC Settings configuration dialog (Even if
you do not have a Tablet PC).
Select the Other Tab.
In the Handedness section, place a check mark in the Left Handed
option.
Click OK.

Horizontal menu?

I want to create a horizontal menu across the top of my user control whose items fill the whole space horizontally. There are six items and it's one level only - so it's not really a menu as such.
Can I do this with a menu? Or am I better off with using a six column grid with a button per col, or even a horizontal stack panel? Here is what I have so far:
<DockPanel>
<DockPanel DockPanel.Dock="Top" KeyboardNavigation.TabNavigation="None">
<Menu KeyboardNavigation.TabNavigation="Cycle" VerticalAlignment="Top" Background="DarkGray" Height="40">
<MenuItem Header="_New"/>
<MenuItem Header="_Load" />
<MenuItem Header="_Save" />
<MenuItem Header="_Validate" />
<MenuItem Header="_Import" />
<MenuItem Header="_Export"/>
</Menu>
</DockPanel>
</DockPanel>
Menu derives from ItemsControl so can just switch the ItemsPanel:
<DockPanel>
<DockPanel DockPanel.Dock="Top" KeyboardNavigation.TabNavigation="None">
<Menu KeyboardNavigation.TabNavigation="Cycle" VerticalAlignment="Top" Background="DarkGray" Height="40">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<MenuItem Header="_New"/>
<MenuItem Header="_Load" />
<MenuItem Header="_Save" />
<MenuItem Header="_Validate" />
<MenuItem Header="_Import" />
<MenuItem Header="_Export"/>
</Menu>
</DockPanel>
</DockPanel>
<Menu KeyboardNavigation.TabNavigation="Cycle" VerticalAlignment="Top" Background="DarkGray" Height="40">
<MenuItem Header="File">
<MenuItem Header="_New"/>
<MenuItem Header="_Load" />
<MenuItem Header="_Save" />
<MenuItem Header="_Validate" />
<MenuItem Header="_Import" />
<MenuItem Header="_Export"/>
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Header="Cut"/>
<MenuItem Header="Copy"/>
<MenuItem Header="Paste" />
</MenuItem>
</Menu>
Hope this will help. you need to add Menu subitems within the MenuItem. it itself is o0f List type.

How to remove or add an item from a WrapPanel?

I am trying to create a prototype where the user can show or display items by selecting the menu items. I need the item to be removed/Collapsed because I need the empty space to be taken by other items in WrapPanel. The content in the wrapPanel is generated dynamically with XMLDataProvider. I tried to assign commands for the menu items but was not able to make it work.
XAML:
<Grid Margin="20">
<Menu x:Name="Manage_Menu" HorizontalAlignment="Left" Background="{x:Null}" ScrollViewer.VerticalScrollBarVisibility="Auto" Foreground="#FF2A2A2A" Margin="0,0,0,5" >
<MenuItem Header="Show/Hide">
<MenuItem Header="1" Command="{x:Static local:MainWindow.FirstThumbVisibilityWindowCommand}" IsCheckable="true" IsChecked="True"/>
<MenuItem Header="2" Command="{x:Static local:MainWindow.FirstThumbVisibilityWindowCommand}" IsCheckable="true" />
<MenuItem Header="3" Command="{x:Static local:MainWindow.FirstThumbVisibilityWindowCommand}" IsCheckable="true" />
<MenuItem Header="4" Command="{x:Static local:MainWindow.FirstThumbVisibilityWindowCommand}" IsCheckable="true" />
<MenuItem Header="5" Command="{x:Static local:MainWindow.FirstThumbVisibilityWindowCommand}" IsCheckable="true" />
</MenuItem>
</Menu>
<Frame Content="Frame" Source="../tiles.xaml" NavigationUIVisibility="Hidden" />
</Grid>
I hope someone will be able to help.
The whole solution is available from here:
http://cid-0c29483cf3a6a14d.office.live.com/self.aspx/WPF%5E_Tests/DragDropWrapPanel%5E_3.rar
Please take a look. You will find Menu on top left corner that should be used to hide/show items inside the wrapPanel.
Thank you in advance.
One way to add or remove items from a wrap panel is use a ListBox with the ItemsPanel configured as a WrapPanel
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
Bind the ListBox to an ObservableCollection and then add and remove your view models from the bound collection.
Here is an example of changing the visibility of WrapPanel items from code.
Some sample XAML:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Button Content="0" Click="Button_Click"/>
<Button Content="1" Click="Button_Click"/>
<Button Content="2" Click="Button_Click"/>
</StackPanel>
<WrapPanel Grid.Row="1" x:Name="wrapPanel">
<Rectangle Fill="Red" Width="100" Height="100"/>
<Rectangle Fill="Green" Width="100" Height="100"/>
<Rectangle Fill="Blue" Width="100" Height="100"/>
</WrapPanel>
</Grid>
and the button event handler:
private void Button_Click(object sender, RoutedEventArgs e)
{
int index = int.Parse((string)((sender as Button).Content));
var child = this.wrapPanel.Children[index];
child.Visibility = child.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
}
which just toggles the visibility of the child corresponding to the text on the button.
Here is a quick-n-dirty version that is XAML only. It uses the built-in BooleanToVisibilityConverter, and Element binding.
<Window x:Class="WrapPanelHideItems.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WrapPanelHideItems" Height="300" Width="300">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="boolToVis" />
</Window.Resources>
<StackPanel>
<Menu>
<MenuItem Header="Show/Hide">
<MenuItem x:Name="mnuItemOne"
IsCheckable="True"
IsChecked="True"
Header="Show Item One" />
<MenuItem x:Name="mnuItemTwo"
IsCheckable="True"
IsChecked="True"
Header="Show Item Two" />
<MenuItem x:Name="mnuItemThree"
IsCheckable="True"
IsChecked="True"
Header="Show Item Three" />
<MenuItem x:Name="mnuItemFour"
IsCheckable="True"
IsChecked="True"
Header="Show Item Four" />
<MenuItem x:Name="mnuItemFive"
IsCheckable="True"
IsChecked="True"
Header="Show Item Five" />
</MenuItem>
</Menu>
<WrapPanel Orientation="Horizontal"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="Gray">
<TextBlock Text="Item One"
Margin="5"
FontSize="25"
Foreground="Red"
Visibility="{Binding ElementName=mnuItemOne, Path=IsChecked,
Converter={StaticResource boolToVis}}"/>
<TextBlock Text="Item Two"
Margin="5"
FontSize="25"
Foreground="Blue"
Visibility="{Binding ElementName=mnuItemTwo, Path=IsChecked,
Converter={StaticResource boolToVis}}"/>
<TextBlock Text="Item Three"
Margin="5"
FontSize="25"
Foreground="Green"
Visibility="{Binding ElementName=mnuItemThree, Path=IsChecked,
Converter={StaticResource boolToVis}}"/>
<TextBlock Text="Item Four"
Margin="5"
FontSize="25"
Foreground="Yellow"
Visibility="{Binding ElementName=mnuItemFour, Path=IsChecked,
Converter={StaticResource boolToVis}}"/>
<TextBlock Text="Item Five"
Margin="5"
FontSize="25"
Foreground="Violet"
Visibility="{Binding ElementName=mnuItemFive, Path=IsChecked,
Converter={StaticResource boolToVis}}"/>
</WrapPanel>
</StackPanel>
</Window>
Of course, in a real-world app, you'd want to use things like Styles and perhaps DataBinding, but this shows that you don't have to be complex to get the results you want. Simpler is usually better.

Resources