1

我正在使用 WPF 和 DevExpress。我想在停靠面板中添加两个按钮。当我添加第二个按钮时,它说: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>
4

1 回答 1

2

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

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

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

于 2013-08-01T15:13:35.223 回答