user301016
user301016

Reputation: 2237

How to add multiple toolbox controls in xaml

Hi ,

I added <Image> // included an image in the window.</Image>

If I wish to add a label just below the image and few other controls, how can i do it?

The XAML Code is shown here.

    <Image
        Name="imgClientPhoto"
        HorizontalAlignment="Left"
        VerticalAlignment="Top"
        Width="auto"
        Height="auto"
        Grid.Column="0"
        Grid.Row="0"
        Margin="0" Source="D:\pic1.gif" MinWidth="450" MinHeight="100" Grid.IsSharedSizeScope="True">

    </Image>
<Label>

</Label>

I added just below the , but an error is seen "The property "content" is set more than once.

Please help me to correct this error.

My intention is to add an image at the top(title), then below it a label,then a dropdown box, treeview.. so on..

Please help the good way to work on this.

Thanks Ramm

Upvotes: 0

Views: 490

Answers (1)

exclsr
exclsr

Reputation: 3357

Panels.

<StackPanel>
    <Image ... />
    <Label ... />
</StackPanel>

Also see <WrapPanel>, <DockPanel>, <Grid>, <Canvas>, etc.

You'll run into that error if you do something like:

<Window ... >
    <Image ... />
    <Label ... /> <!-- Won't work -->
</Window>

This is because many controls in WPF are ContentControls, like Window, and these sorts of controls can only have one child. To have more than one child, use a Panel.

Upvotes: 2

Related Questions