views:

151

answers:

1

Is is possible to make the contents(children) of a WrapPanel to be bound to a dependency property?

What I am thinking is having a dependency property that is of type List and then define a template for MyClass.

Then have the WrapPanel display them.

I know this is much easier done with a list box, but due to other constraints, I need to try with a WrapPanel before going to a list box.

I am using MVVM. I would prefer doing this in that pattern. If I were to break out of MVVM I could just use an event or name it and fill it at load time. I am hoping there is a binding way that is cleaner.

+5  A: 

ItemsControl is your friend:

<ItemsControl ItemsSource="{Binding YourChildItems}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

HTH,
Kent

Kent Boogaart
Not what I was looking for. But I will take it. (I needed a control with `Childern` that could be bound to. I modified my scenario to fit this though.
Vaccano
The items of the `ItemsControl` become the children of the `ItemsControl`'s panel.
Kent Boogaart