在XAML中显示动态大小列表(只读)

[英]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.

这样做的最好方法是什么?我唯一能想到的是创建一个带有ItemTemplate的ListView。但是这些项目是可选择的,这不是我想要的。如果我将列表设为只读,它将变为灰色。不喜欢那样。

Anyone has a better suggestion?

有人有更好的建议吗?

2 个解决方案

#1


<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.

如果您希望所有项目排列良好,请使用带有SharedSizeGroup的ItemsControl.ItemsPanel网格。

#2


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

请看这里:http://www.codeplex.com/wpg或这里http://dvuyka.spaces.live.com/blog/cns!305B02907E9BE19A!448.entry

They are both implmentations of PropertyGrid from WinForms

它们都是来自WinForms的PropertyGrid的实现

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2009/06/23/7203f6a9b132ff0f7a26aa34aaadda9f.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告