Question

I'm quite new to WPF and have to create an application. I have a window (MainWindow), with a main menu at the top of it with 5 menu items.

I don't want to create new pop-up windows for each menu items but I'd like my program to respond the menuitems and so displays other and other surfaces inside this MainWindow (the menu will be statically at the same position).

I found UserControl and this will be a solution if you don't suggest anything else. Might be easy question for you, but also a big help for me. Thank you.

Was it helpful?

Solution

all you need is a toolbar with toolbaritem for your menu and a contentcontrol where you set the content property to the content in dependence of your menu item. and if you do a little bit MVVM you simply set the vm to the content property and define some datatemplates for your views.

<Window>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Height="auto" />
            <ColumnDefinition Height="*" />
        </Grid.ColumnDefinitions>

        <ToolBar Grid.Column="0">

        </ToolBar>

        <ContentControl Grid.Column="1" Content="{Binding Path=ActualWorkspace}" />

    </Grid>
  </Window>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top