Reputation: 382
I am trying to add two ComboBoxes inside a Layout Panel as shown in the code below.
But I am encountering an error - "The property 'Content' is set more than once". How do I add two combo boxes inside a Layout?
<!--User Control Layout-->
<dxdo:LayoutGroup x:Name="LayoutGroupTopLevel">
<dxdo:LayoutGroup x:Name="GridViews" ItemWidth="1*" Orientation="Vertical" AllowClose="True" AllowDock="True" AllowFloat="True" AllowHide="True">
<dxdo:LayoutPanel x:Name="Layers" Caption="User Control" ItemHeight="1*">
<dxdo:LayoutGroup>
<dxlc:LayoutItem Label="Plan Type">
<dxe:ComboBoxEdit Height="25" VerticalAlignment="Top" Width="200" Name="BoxEdit">
<dxe:ComboBoxEditItem Content="3 month"/>
<dxe:ComboBoxEditItem Content="2 year"/>
</dxe:ComboBoxEdit>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Site">
<dxe:ComboBoxEdit Height="25" VerticalAlignment="Top" Width="200" Name="BoxEdit1"/>
</dxlc:LayoutItem>
</dxdo:LayoutGroup>
</dxdo:LayoutPanel>
<dxdo:LayoutPanel x:Name="LayoutPanel" Caption="Properties" ItemHeight="1*">
<dxlc:LayoutItem Label="Site">
<dxe:ComboBoxEdit Height="25" VerticalAlignment="Stretch" Width="200" Name="ComboBoxEdit"/>
<dxe:ComboBoxEdit Height="25" VerticalAlignment="Stretch" Width="200" Name="ComboBoxEdit1"/>
</dxlc:LayoutItem>
</dxdo:LayoutPanel>
</dxdo:LayoutGroup>
Can anyone please point out the mistake I am committing?
Upvotes: 1
Views: 638
Reputation: 10349
Assuming you're using DevExpress WPF controls suite, your error is trying to add two LayoutItem
s to a LayoutPanel
. It only supports either a single UIElement
or a LayoutGroup
as content (see LayoutPanel documentation, section "Content"). So to complete your goal you should wrap the items with a LayoutGroup
:
<dxdo:LayoutPanel x:Name="Layers" (...)>
<dxdo:LayoutGroup>
<dxlc:LayoutItem Label="Plan Type">(...)</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Site">(...)</dxlc:LayoutItem>
</dxdo:LayoutGroup>
</dxdo:LayoutPanel>
UPDATE
As you pointed out (and it slipped my attention) you cannot directly add a dxlc:LayoutItem
into a dxdo:LayoutGroup
; you should wrap it in a dxdo:LayoutControlItem
(again, it's all in the documentation):
<dxdo:LayoutPanel x:Name="Layers" (...)>
<dxdo:LayoutGroup>
<dxdo:LayoutControlItem>
<dxlc:LayoutItem Label="Plan Type">(...)</dxlc:LayoutItem>
</dxdo:LayoutControlItem>
<dxdo:LayoutControlItem>
<dxlc:LayoutItem Label="Site">(...)</dxlc:LayoutItem>
</dxdo:LayoutControlItem>
</dxdo:LayoutGroup>
</dxdo:LayoutPanel>
Alternatively, you can drop dxlc:LayoutItem
altogether and use only dxdo:LayoutControlItem
(use Caption
property instead of Label
):
<dxdo:LayoutPanel x:Name="Layers" (...)>
<dxdo:LayoutGroup>
<dxdo:LayoutControlItem Caption="Plan Type">(...)</dxdo:LayoutControlItem>
<dxdo:LayoutControlItem Caption="Site">(...)</dxdo:LayoutControlItem>
</dxdo:LayoutGroup>
</dxdo:LayoutPanel>
CLARIFICATION
To disambiguate:
xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
Upvotes: 2