WPF C# 问题:如何在 Visual Studio 中创建像工具箱、服务器资源管理器这样的停靠面板?



我的问题是如何在Windows Presentation Foundation c#上创建停靠面板?我不知道它是对接面板的调用是真是假,因为有些文档是这样调用的。但它就像工具箱,Visual Studio中的服务器资源管理器。我搜索了那么多文件,但什么都没有,每件事都是笼统的,以显示视图。 我想知道如何编码来创建它。我首先对不起,因为我有一个愚蠢的问题。那么我可以帮我这样做吗?或者有一些文件可以帮助我?谢谢!

可以通过调用 DockPanel 在 xaml 代码中创建停靠面板,然后将属性 lastchildfill 设置为 true,以便创建的元素的顺序将确定它们的行为方式并定义它们在窗口中的位置,如下面的代码所示。

<Grid>
<DockPanel LastChildFill="True">
<StackPanel DockPanel.Dock="Left" Width="50" HorizontalAlignment="Left" Background="Aqua">
<Label Content="1" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel DockPanel.Dock="Top" Background="Beige" Height="50">
<Label Content="2" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel DockPanel.Dock="Bottom" Background="Red" Height="100">
<Label Content="3" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel DockPanel.Dock="Right" Background="Yellow" Width="100">
<Label Content="4" HorizontalAlignment="Center"/>
</StackPanel>[![enter image description here][1]][1]
<StackPanel DockPanel.Dock="Bottom" Background="Gray" Height="50">
<Label Content="5" HorizontalAlignment="Center"/>
[![enter image description here][1]][1]</StackPanel>
<StackPanel DockPanel.Dock="Right" Background="Black" Width="50">
<Label Content="6" HorizontalAlignment="Center" Background="White"/>
</StackPanel>
</DockPanel>
</Grid>

相关内容

最新更新