0
votes

How to dynamically change a module to a region of the main page according to menus / sub menus in WPF using MVVM and Unity Bootstrapper ?

I've the main page like :-

       <Menu Width="Auto" HorizontalAlignment="Right" Grid.Row="1" Background="Transparent">
            <MenuItem Header="General" x:Name="mnuDeposit" Margin="0" Padding="0" Width="85">
                <MenuItem Header="PayPal" x:Name="mnuDepositPayPal" />                   
            </MenuItem>
            <MenuItem Header="Admin" x:Name="mnuMsg" Margin="0"  Padding="0" Width="98">
                <MenuItem Header="Register Admin" x:Name="mnuRegAdmin" Click="mnuRegAdmin_Click" />

            </MenuItem>
        </Menu>

        <ItemsControl Name="MainRegion" prism:RegionManager.RegionName="MainRegion" Grid.Row="2"/>

Now I want the "MainRegion" will be binded to different view according to the menu item. The view has a view model and uses MVVM, Prism and Unity Bootstrapper.

1
Please add as more details about the problem - Eldho
I've provided the details please check. - agileDev

1 Answers

0
votes

First, prefer commands (in the view model) to event handlers (in the view).

Second, if you want to display one view at a time in your MainRegion, go for ContentControl.

Third, in the command bound to the menu items, use RegionManager.RequestNavigate to set the content of the region.