Jacek Wojcik
Jacek Wojcik

Reputation: 1253

Border with more then one child

I have a Border.

I have a TextBlock displayed on it:

TextBlock tb = new TextBlock();
myBorder.Child = tb;

And it works fine.

The thing is: I also want to have CheckBox displayed on it.

The problem is that border is a single child element.

Is there any workaround here?

Thank you!

Upvotes: 4

Views: 7289

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273209

The problem is that border is a single child element...

Correct, Border is a ContentControl and they, by design, can only contain 1 child.

So... is there any workaround here?

Yes, just place a Grid, StackPanel or any other LayoutControl (Panel) inside the Border. This is a general approach that lets you create arbitrary complex content.

Upvotes: 11

Related Questions