如何在dock面板中添加两个或多个按钮



我正在使用WPF和DevExpress。我想在dock面板中添加两个按钮。当我添加第二个按钮时,上面写着:Content is set more than once。为什么会这样?我犯了什么错误吗?或者被告席不允许这样做。

<dxdo:DockLayoutManager Margin="0,-3,-156,0" HorizontalAlignment="Right" VerticalAlignment="Top" Background="White" Height="243" Width="109">
    <dxdo:LayoutGroup Caption="LayoutRoot" Margin="0,0,0,172">
        <dxdo:LayoutGroup Orientation="Vertical">
            <dxdo:LayoutPanel  x:Name="Panel1"  ShowCloseButton="False" ShowMaximizeButton="False" ShowPinButton="False" ShowRestoreButton="False" ShowControlBox="False" AllowDock="False" AllowDrag="False" AllowFloat="False" AllowHide="False" AllowClose="False" AllowActivate="False" AllowMinimize="False" AllowMaximize="False">
                <Button x:Name="ToggleButton1" Content="New" Click="ToggleButton_Click" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                <Button Content="Delete Focused Row"
                Click="DeleteButton_Click33"
                Grid.Column="1" />
            </dxdo:LayoutPanel>
            <dxdo:LayoutPanel  x:Name="Panel2" ShowCloseButton="False" ShowMaximizeButton="False" ShowPinButton="False" ShowRestoreButton="False" ShowControlBox="False" AllowDock="False" AllowDrag="False" AllowFloat="False" AllowHide="False" AllowClose="False" AllowActivate="False" AllowMinimize="False" AllowMaximize="False">
                <Button x:Name="ToggleButton2" Content="Close" Click="ToggleButton2_Click" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            </dxdo:LayoutPanel>
        </dxdo:LayoutGroup>
    </dxdo:LayoutGroup>
</dxdo:DockLayoutManager>

您可以在LayoutPanel.Content属性中放置多个控件。只需将按钮包装到面板中即可:

<dxdo:LayoutPanel ... >
    <StackPanel Orientation="Vertical">
        <Button x:Name="button1" ... />
        <Button x:Name="button2" ...  />
    </StackPanel>
</dxdo:LayoutPanel>

相关示例:如何在LayoutPanels 中构建控件布局

最新更新