我的問題很簡單,我可以從 LinkedList 中的元素在 StackPanel 中使用系結嗎?在我的應用程式中,LinkedList 中元素的順序很重要。可能元素可以動態更改其在 LinkedList 中的位置。我想知道是否可以系結我的 LinkedList,以便我的應用程式始終以正確的順序顯示元素,而無需任何額外的 C# 代碼/事件觸發器。
可以在 WPF 中做到這一點嗎?
我該如何實施?
uj5u.com熱心網友回復:
只需將ItemsSourcean的屬性設定或系結ItemsControl到您的鏈表:
ic.ItemsSource = yourList;
...和可選定義自定義ItemsPanelTemplate為ItemsControl:
<ItemsControl x:Name="ic">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/354196.html
上一篇:WPF系結自定義串列索引器
