2

我想使用以下布局结构构建一个 WPF 窗口应用程序。考虑左侧框架/窗口上的标题和按钮,例如 ASP.Net 中的“母版页”。在右侧框架上,它应该是一个 WPF 导航窗口。

当我在最后一个堆栈面板中包含导航窗口作为 UI 元素时,它会抛出错误。我应该如何根据下面的图像截图设计整个布局?谢谢

<Window x:Class="MainWindow"
     xmlns:local="clr-namespace:ClientSocket"        
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title=" Desktop" Height="841" Width="1271" WindowStartupLocation="CenterScreen" WindowState="Maximized">
    <DockPanel>
        <StackPanel DockPanel.Dock ="Top"  Orientation="Horizontal" Background="Red">
            <TextBlock  Background="red"  FontSize ="36" Width="482" >
           Main Title
            </TextBlock>          
        </StackPanel>
        <StackPanel Background="LightGray" DockPanel.Dock ="Left" Width="145">
            <Button Content="Button1" Name="btnAndroid" Width="119" Margin="3" BorderBrush="{StaticResource {x:Static SystemColors.InfoBrushKey}}" />
            <Button Content="Button2" Name="btnDownloads" Width="119" Margin="3" BorderBrush="{StaticResource {x:Static SystemColors.InfoBrushKey}}" />
            <Button Content="AddNewDownloads" Height="37" Name="Button1" Width="133" />
        </StackPanel>
        <StackPanel>
        <NavigationWindow Height="auto" Width="auto" Name="nwMain" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="Blue" BorderThickness="1"  />
        </StackPanel>
    </DockPanel>
</Window>

在此处输入图像描述

4

1 回答 1

3

您不能将窗口添加为任何东西的子窗口,您可以在此处使用可嵌套的导航控件,它被称为Frame.

布局方面我会推荐一个Grid有两的,包含另一个有两的网格(in )。Grid.Row="1"

DockPanels是可能不应该使用的悲伤控制,除非有人用枪指着你并告诉你。

于 2011-11-24T03:02:45.287 回答