How to put more than one control in a TabItem of a TabControl?

0

I'm working with WPF, Visual Studio 2015.

The problem I have is the following I have a TabControl with tabItems, in a tabitem I added a label control without problems but when I add another label it gives me the following message: "The content property is set more than one Once. ", in a tabItem you can only accept a secondary element.

<TabItem Header="Lista">
            <Label x:Name="label" Content="Nombre:" Margin="10,13,219,226"  />
            <Label x:Name="label1" Content="Label" Height="100" Width="100"/>
        </TabItem>

To avoid that mistake I did the following:

<TabItem Header="Lista">
            <Label x:Name="label1" Margin="10,13,219,226">Nombre:</Label>
            <Label x:Name="label2">Dirección:</Label>
        </TabItem>

But I still get the same error, do I have to configure the TabControl control? How can I solve it?

    
asked by Pedro Ávila 07.10.2017 в 17:28
source

1 answer

1

In wpf you have to use containers like: StackPanel , Grid , etc

Overview of WPF container controls

to be able to locate more than one control you would use

<TabItem Header="Lista">
    <StackPanel>
        <Label x:Name="label1" Margin="10,13,219,226">Nombre:</Label>
        <Label x:Name="label2">Dirección:</Label>
    </StackPanel>
</TabItem>

or if you want to control the layout better the grid will give you more flexibility, as explained here

Tab Control in WPF

    
answered by 07.10.2017 / 19:59
source