Frage

I am using WPF and DevExpress. I want to add two buttons in dock panel. As I added 2nd button it said: 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>
War es hilfreich?

Lösung

You can place more than one control into the LayoutPanel.Content property. 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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top