views:

73

answers:

2

I have 2 ItemsControls parallel to each other. The first is a set of TextBlocks with Property names and the second is a set of TextBoxes with Property values.

Property1 Value1

Property2 Value2

Property3 Value3

" "

The list goes on very long in some cases.

Is there a way to possibly break the columns at a certain point and 'wrap' the two ItemsControls so they begin 2 new columns (parallel to the first 2) in the same container?

A: 

My understanding of this question is that you are dynamically creating the Propertyn, Valuen TextBlocks.

Host the whole thing in a WrapPanel control.

For each pair of TextBlocks you dynamically create, create a new Grid control, and place the two TextBlocks in this Grid control and place the Grid control in the WrapPanel control.


Edit After Pavel's comment, I realise that you currently have the two lists as two single separate controls. My solution suggests a completely different approach.

Andrew Shepherd
What "each pair"? He only has 2 `ItemControl`s in all here.
Pavel Minaev
@Paul: Oops, I misread the question. I was thinking each pair of text blocks, but you're right, they're just two separate lists.
Andrew Shepherd
A: 

I'm pretty confident that this cannot be done. This isn't even ItemsControl-specific - your question really boils down to, "how do I take two separate WPF controls, and make their children display in interleaved manner?". It just doesn't work that way - after all, an ItemsControl is still a UIElement, and has well-defined Width and Height. In your example with two interleaves ItemsControls, what would be the width of each?

Pavel Minaev