I want to create a wpf application with a menubar. The Menubar has some clickable elements, which opens a new window. Because the menubar is the same on every window, I want to create the menubarcode just once.
I read here how to create a menubar (What is the accepted way to get a main window with menubar and toolbar in WPF?):
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="self"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Menu Grid.Row="0">
<MenuItem Header="File">
<MenuItem Header="Open" />
<MenuItem Header="Close" />
</MenuItem>
</Menu>
<ToolBar Grid.Row="1">
<Button Content="Foo" />
<Button Content="Bar" />
</ToolBar>
</Grid>
</Window>
I read also the question for the same header an footer for alle wpf windows: Same header & footer in all WPF windows. There they suggest a usercontrol.
The Question How to make a Template Window in WPF? doesn't solve my issue. Is it possible to add clicklistener to the template? I do not want to implement all clicklistener on every window. My menubar/toolbar only opens some other windows. Only for diplaying static content the solution would work.
What is the best practice for this kind of problem?