WPF DevComponents Dock Control 不会填满屏幕
Posted
技术标签:
【中文标题】WPF DevComponents Dock Control 不会填满屏幕【英文标题】:WPF DevComponents Dock Control will not fill screen 【发布时间】:2010-08-23 23:11:10 【问题描述】:我正在使用 DevComponents 第三方控件来创建一个屏幕,其中包含多个按三行组织的停靠组件,最后一行有三列。我已经成功地创建了这个布局,但是我不知道如何将 DockSite 的高度扩展到屏幕的边界。
我在下面发布了 XAML:
<UserControl x:Class="Docking_UC"
xmlns:my="clr-namespace:DevComponents.WpfDock;assembly=DevComponents.WpfDock"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="714" Width="1057">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="83"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid HorizontalAlignment="Stretch" Margin="0" Name="bodyGrid" Width="Auto" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="71" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<WrapPanel>
<Label>Dock Test #</Label>
<Label>1</Label>
</WrapPanel>
<Rectangle Height="12" Name="menuRectangle" Stroke="Black" VerticalAlignment="Bottom" Fill="SteelBlue" Opacity="0.25" Grid.Row="1" />
</Grid>
<my:DockSite Background="Transparent" Name="dashDockSiteAll" Grid.Row="1">
<my:DockSite.SplitPanels>
<my:SplitPanel Orientation="Vertical" my:DockSite.Dock="Top" my:DockSite.DockSize="714">
<my:SplitPanel Orientation="Vertical">
<my:DockWindowGroup my:SplitPanel.RelativeSize="50,135">
<my:DockWindow Header="Top" Name="dockWindowTop">
<Label>2</Label>
</my:DockWindow>
</my:DockWindowGroup>
<my:DockWindowGroup my:SplitPanel.RelativeSize="50,220">
<my:DockWindow Header="MidWindowTab1" Name="dockWindowMid1">
<Label>3</Label>
</my:DockWindow>
<my:DockWindow Header="MidWindowTab2" Name="dockWindowMid2">
<Label>4</Label>
</my:DockWindow>
</my:DockWindowGroup>
<my:DockWindowGroup my:SplitPanel.RelativeSize="50,150">
<my:DockWindow Header="Bottom" Name="dockWindowBottom">
<my:SplitPanel Orientation="Horizontal" my:SplitPanel.RelativeSize="50,150">
<my:DockWindowGroup>
<my:DockWindow Header="BottomLeft">
<Label>5</Label>
</my:DockWindow>
</my:DockWindowGroup>
<my:DockWindowGroup>
<my:DockWindow Header="BottomMid">
<Label>6</Label>
</my:DockWindow>
</my:DockWindowGroup>
<my:DockWindowGroup>
<my:DockWindow Header="BottomRight">
<Label>7</Label>
</my:DockWindow>
</my:DockWindowGroup>
</my:SplitPanel>
</my:DockWindow>
</my:DockWindowGroup>
</my:SplitPanel>
</my:SplitPanel>
</my:DockSite.SplitPanels>
</my:DockSite>
</Grid>
我已尝试删除 DockSite.Site 属性,但 DockSite 默认为 Left Docked。此外,在将一个窗口停靠到底部站点时,仍然有一个大约光标高度的空白区域,我无法删除。
【问题讨论】:
【参考方案1】:好的,所以经过一天的故障排除/弄乱控件后,我终于发现了我一直在努力完成的事情。我在标签外的 DockSite 添加了一个 my:SplitPanel,显然这个 SplitPanel 会自动停靠到剩余的空白处。
更正的代码如下,添加的内容被猥亵的标签覆盖:
<UserControl x:Class="Docking_UC" xmlns:my="clr-namespace:DevComponents.WpfDock assembly=DevComponents.WpfDock" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="714" Width="1057">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="83"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid HorizontalAlignment="Stretch" Margin="0" Name="bodyGrid" Width="Auto" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="71" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<WrapPanel>
<Label>Dock Test #</Label>
<Label>1</Label>
</WrapPanel>
<Rectangle Height="12" Name="menuRectangle" Stroke="Black" VerticalAlignment="Bottom" Fill="SteelBlue" Opacity="0.25" Grid.Row="1" />
</Grid>
<my:DockSite Background="Transparent" Name="dashDockSiteAll" Grid.Row="1">
<my:DockSite.SplitPanels>
<my:SplitPanel Orientation="Vertical" my:DockSite.Dock="Top" my:DockSite.DockSize="714">
<my:SplitPanel Orientation="Vertical">
<my:DockWindowGroup my:SplitPanel.RelativeSize="50,135">
<my:DockWindow Header="Top" Name="dockWindowTop">
<Label>2</Label>
</my:DockWindow>
</my:DockWindowGroup>
<my:DockWindowGroup my:SplitPanel.RelativeSize="50,220">
<my:DockWindow Header="MidWindowTab1" Name="dockWindowMid1">
<Label>3</Label>
</my:DockWindow>
<my:DockWindow Header="MidWindowTab2" Name="dockWindowMid2">
<Label>4</Label>
</my:DockWindow>
</my:DockWindowGroup>
</my:SplitPanel>
</my:SplitPanel>
</my:DockSite.SplitPanels>
<my:SplitPanel Orientation="Horizontal" my:DockSite.DockSize="100">
<my:SplitPanel Orientation="Horizontal" my:SplitPanel.RelativeSize="50,100">
<my:DockWindowGroup>
<my:DockWindow Header="BottomLeft">
<Label>5</Label>
</my:DockWindow>
</my:DockWindowGroup>
<my:DockWindowGroup>
<my:DockWindow Header="BottomMid">
<Label>6</Label>
</my:DockWindow>
</my:DockWindowGroup>
<my:DockWindowGroup>
<my:DockWindow Header="BottomRight">
<Label>7</Label>
</my:DockWindow>
</my:DockWindowGroup>
</my:SplitPanel>
</my:SplitPanel>
</my:DockSite>
</Grid>
希望这可以帮助遇到同样问题的其他人。
另外,如果有足够声誉的人读到这篇文章,请您添加一个 DevComponents 标记吗?
【讨论】:
以上是关于WPF DevComponents Dock Control 不会填满屏幕的主要内容,如果未能解决你的问题,请参考以下文章
VS2010引用第三方控件DevComponents.DotNetBar2出现问题
在 Avalon dock 中,LayoutAnchorable WPF 应用程序没有出现 Title 和 Dock 组合按钮选项
具有依赖属性绑定到 DockPanel.Dock 附加属性的 WPF 自定义控件不起作用