WPF DevComponents Dock Control不会填充屏幕

时间:2010-08-23 23:11:11

标签: c# wpf dock docking

我正在使用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 个答案:

答案 0 :(得分:1)

好的,所以在经过另一天的故障排除/搞乱控制后,我终于发现了我一直想要完成的事情。我在标签外面添加了一个my:SplitPanel到DockSite,显然这个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标签?