简体   繁体   English

如何在停靠面板中添加两个或更多按钮?

[英]how to add two or more buttons in dock panel?

I am using WPF and DevExpress. 我正在使用WPF和DevExpress。 I want to add two buttons in dock panel. 我想在停靠面板中添加两个按钮。 As I added 2nd button it said: Content is set more than once . 当我添加第二个按钮时,它说: Content is set more than once Why is it so ? 为什么会这样呢? Did I made any mistake or is dock panel doesn't allow this. 我是否犯了任何错误,或者码头面板不允许这样做?

<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>

You can place more than one control into the LayoutPanel.Content property. 您可以在LayoutPanel.Content属性中放置多个控件。 Just wrap your buttons into panel: 只需将按钮包装到面板中即可:

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

Related example: How to build a layout of controls within LayoutPanels 相关示例: 如何在LayoutPanels中构建控件的布局

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM