2010-03-28 243 views

回答

5

我一直在使用Samuel的解決方案,它的工作得很好。

http://blog.functionalfun.net/2009/02/how-to-databind-to-selecteditems.html

+0

Jobi Joy的答案非常簡單,工作正常。爲什麼要通過閱讀博客文章重新發明輪子並浪費時間?美麗是在簡單:) – Stacked 2013-05-14 15:31:40

+0

@Stacked:可能是因爲jobi的解決方案涉及2個列表框,而OP可能希望他的選定項目在同一個列表框中表示他的源項目。 – Terry 2013-10-29 12:10:08

+0

@Derry你不需要使用2個ListBox,我只是喜歡使用ElementName屬性的想法。 – Stacked 2013-10-29 23:19:43

1

您可以使用ListBox.SelectedItems屬性爲此。

<ListBox x:Name="listBox" SelectionMode="Multiple" ItemsSource="{Binding YourCollection}" /> 
    <ListBox ItemsSource="{Binding SelectedItems , ElementName=listBox}"/> 
+0

的問題問到綁定的SelectedItem(我相信他們的意思SelectedItems)的列表,而不是到另一個ListBox的的ItemsSource。 – Kohanz 2017-02-08 19:52:51

相關問題