StackPanel 在 WPF 中的布局中显示框架 xaml

StackPanel show Frame in Layout in WPF and xaml

我在一个 DockPanel 中创建了 4 个 stackPanel

哪个面板只是一帧window

然后我创建一个网格以包含左 StackPanel 和右 StackPannel

现在我在底部框架中添加了一个按钮,用于切换左右隐藏

并显示 VCenter Frame 或反转。但是我不知道做这个功能。

有人给我推荐吗?

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="PanelUserCtrlSample.MainWindow"
    Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<DockPanel LastChildFill="True">
    <StackPanel DockPanel.Dock="Top" Width="Auto" Height="50" Background="Red">
        <Frame x:Name="frmMainTop" NavigationUIVisibility="Hidden">
        </Frame>
    </StackPanel>
    <StackPanel DockPanel.Dock="Bottom" Width="Auto" Height="50" Background="Blue">
        <Frame x:Name="frmMainBottom" NavigationUIVisibility="Hidden">
        </Frame>
    </StackPanel>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="83*"/>
            <ColumnDefinition Width="434*"/>
        </Grid.ColumnDefinitions>

        <!--Full Screen-->

        <!--<StackPanel  DockPanel.Dock=""  Grid.ColumnSpan="2" Width="Auto" Height="Auto" Background="Black">
            <Frame x:Name="frmMainFull" NavigationUIVisibility="Hidden">

            </Frame>
        </StackPanel>-->

        <!--VCenter-->
        <StackPanel  DockPanel.Dock="Left"  Grid.ColumnSpan="2" Width="Auto" Height="Auto" Background="Black">
            <Frame x:Name="frmMainVCenter" NavigationUIVisibility="Hidden">

            </Frame>
        </StackPanel>

        <!--left-->
        <StackPanel  DockPanel.Dock="Left"  Grid.Column="0" Width="Auto" Height="Auto" Background="Green">
            <Frame x:Name="frmMainLeft" NavigationUIVisibility="Hidden">

            </Frame>
        </StackPanel>

        <!--Right-->
        <StackPanel Grid.Column="1" Background="Pink">
            <Frame x:Name="frmMainRight" NavigationUIVisibility="Hidden">

            </Frame>
        </StackPanel>
    </Grid>
</DockPanel>

MainWindow_Loaded

private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        frmMainTop.NavigationService.Navigate(new PageTop1());
        frmMainLeft.NavigationService.Navigate(new PageLeft1());
        frmMainRight.NavigationService.Navigate(new PageRight1());
        frmMainBottom.NavigationService.Navigate(new PageBottom1());
    }

文件列表

如果我想创建一个完整的堆栈面板,我该如何实现它。

我得到了要实施的解决方案。

MainWindow rootwindow = (MainWindow)Application.Current.MainWindow;
rootwindow.spMainLeft.Visibility = Visibility.Hidden;
rootwindow.spMainRight.Visibility = Visibility.Hidden
rootwindow.pageBottom.lblBottom.Content = "Change";