user2556845
user2556845

Reputation: 1

The property 'Content' is set more than once,how to set textboxes in xaml

I am getting the following error with my code shown below:

<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
        <Button Background="Orange" FontStyle="Italic" Padding="8,4" Margin="4">Styles</Button>
        <Button Background="Orange" FontStyle="Italic" Padding="8,4" Margin="4">are</Button>
        <Button Background="Orange" FontStyle="Italic" Padding="8,4" Margin="4">cool</Button>
    </StackPanel>

Error:

The property 'Content' is set more than once

Upvotes: 0

Views: 1653

Answers (1)

Tal Malaki
Tal Malaki

Reputation: 422

As said before me the XAML code you posted is correct. What happend is that you put your stackPanel outside another stackPanel or a grid. A window in WPF can only have one content control, these are Grid, Canvas, StackPanel or DockPanel. You cannot write in XAML 2 stackPanles one under the other or any other 2 or more combinations of any Panel.

Upvotes: 2

Related Questions