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?
有人有更好的建議嗎?
<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網格。
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的實現
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/06/23/7203f6a9b132ff0f7a26aa34aaadda9f.html。