所以我想知道在用户控件/页面上将 HorizontalAlignment 设置为左侧时是否可以在页面上拉伸扩展器。
问题是我们不想在扩展器上设置宽度,因为我们希望在调整应用程序大小时调整它的大小。我们也不能在扩展器上设置最小宽度,因为我们的应用程序也有 850 的最小宽度和 1200 的正常宽度,我们希望扩展器始终拉伸到最大尺寸。
代码示例:
<UserControl x:Class="WpfApp1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
d:DesignWidth="1100" HorizontalAlignment="Left">
<DockPanel>
<StackPanel>
<Expander Background="LightBlue"/>
</StackPanel>
</DockPanel>
</UserControl>
我们的主要目标是创建类似于下图的内容,其中单选按钮始终位于右侧,并且扩展器的大小适合其可用空间。
如果您使用的DockPanel
只是将其Dock
属性用于子元素并设置LastChildFill="True"
(Expander
当然应该是最后一个子元素)。
像这样的东西:
<DockPanel LastChildFill="True">
<RadioButton DockPanel.Dock="Right" Content="Active"/>
<Expander DockPanel.Dock="Left" Header="title1" Background="LightBlue"/>
</DockPanel>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句