Robbert Dam
Robbert Dam

Reputation: 4107

Showing a dynamic size list in XAML (readonly)

I want to show a list of "properties" in my application. A property is simply a name/value pair. The number of properties is dynamic.

The best way to do this? The only thing I can come up with is creating a ListView with an ItemTemplate. But then the items are selectable, and that's not what I want. If I make the list read-only, it becomes gray. Don't like that either.

Anyone has a better suggestion?

Upvotes: 0

Views: 1266

Answers (2)

Kent Boogaart
Kent Boogaart

Reputation: 178770

<ScrollViewer>
    <ItemsControl ItemsSource="{Binding Properties}">
        <ItemsControl.ItemTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}"/>
                <TextBlock Text="{Binding Value}"/>
            </StackPanel>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>

Use a Grid for ItemsControl.ItemsPanel with SharedSizeGroup if you want all items to line up nicely.

Upvotes: 3

Timotei
Timotei

Reputation: 1919

Look here: http://www.codeplex.com/wpg or here http://dvuyka.spaces.live.com/blog/cns!305B02907E9BE19A!448.entry

They are both implmentations of PropertyGrid from WinForms

Upvotes: 0

Related Questions