@@ -28,6 +28,18 @@ public ObservableCollection<UserInfo> ItemsSource
2828
2929 public static readonly DependencyProperty ItemsSourceProperty =
3030 DependencyProperty . Register ( "ItemsSource" , typeof ( ObservableCollection < UserInfo > ) , typeof ( MultiSelectComboBoxExample ) , new PropertyMetadata ( null ) ) ;
31+
32+
33+ public ObservableCollection < StkInfo > StkInfoList
34+ {
35+ get { return ( ObservableCollection < StkInfo > ) GetValue ( StkInfoListProperty ) ; }
36+ set { SetValue ( StkInfoListProperty , value ) ; }
37+ }
38+
39+ public static readonly DependencyProperty StkInfoListProperty =
40+ DependencyProperty . Register ( "StkInfoList" , typeof ( ObservableCollection < StkInfo > ) , typeof ( MultiSelectComboBoxExample ) , new PropertyMetadata ( null ) ) ;
41+
42+
3143 public MultiSelectComboBoxExample ( )
3244 {
3345 InitializeComponent ( ) ;
@@ -44,6 +56,13 @@ private void MultiSelectComboBoxExample_Loaded(object sender, RoutedEventArgs e)
4456
4557 ItemsSource = new ObservableCollection < UserInfo > ( list2 ) ;
4658 SelectedItems = new ObservableCollection < UserInfo > ( list2 . Where ( x => x . ID == "1" || x . ID == "3" ) ) ;
59+
60+ var stkInfos = new List < StkInfo > ( ) ;
61+ stkInfos . Add ( new StkInfo ( ) { StkName = "平安银行" , StkId = "000001" , StkType = "sz" , StkTypeName = "深A" } ) ;
62+ stkInfos . Add ( new StkInfo ( ) { StkName = "上证指数" , StkId = "000001" , StkType = "sh" , StkTypeName = "指数" } ) ;
63+ stkInfos . Add ( new StkInfo ( ) { StkName = "浦发银行" , StkId = "600000" , StkType = "sh" , StkTypeName = "沪A" } ) ;
64+ StkInfoList = new ObservableCollection < StkInfo > ( stkInfos ) ;
65+
4766 }
4867
4968 private void Button_Click ( object sender , System . Windows . RoutedEventArgs e )
@@ -54,4 +73,19 @@ private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
5473 WPFDevelopers . Controls . MessageBox . Show ( message , "选中内容" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
5574 }
5675 }
76+ public class StkInfo
77+ {
78+ public string StkId { get ; set ; }
79+ public string StkName { get ; set ; }
80+ public string StkType { get ; set ; }
81+ public string StkTypeName { get ; set ; }
82+ public string StkFull
83+ {
84+ get
85+ {
86+ return StkType + StkId ;
87+ }
88+ }
89+
90+ }
5791}
0 commit comments