diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml
index c2b57c91..accea93d 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml
@@ -16,66 +16,83 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml.cs
index e31d6848..419d53fc 100644
--- a/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml.cs
+++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/MultiSelectSearchComboBoxExample.xaml.cs
@@ -1,5 +1,5 @@
-using ICSharpCode.AvalonEdit.Document;
-using System.Collections.Generic;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
@@ -11,6 +11,24 @@ namespace WPFDevelopers.Samples.ExampleViews
///
public partial class MultiSelectSearchComboBoxExample : UserControl
{
+ public ObservableCollection SelectedItems
+ {
+ get { return (ObservableCollection)GetValue(SelectedItemsProperty); }
+ set { SetValue(SelectedItemsProperty, value); }
+ }
+
+ public static readonly DependencyProperty SelectedItemsProperty =
+ DependencyProperty.Register("SelectedItems", typeof(ObservableCollection), typeof(MultiSelectSearchComboBoxExample), new PropertyMetadata(null));
+
+ public ObservableCollection ItemsSource
+ {
+ get { return (ObservableCollection)GetValue(ItemsSourceProperty); }
+ set { SetValue(ItemsSourceProperty, value); }
+ }
+
+ public static readonly DependencyProperty ItemsSourceProperty =
+ DependencyProperty.Register("ItemsSource", typeof(ObservableCollection), typeof(MultiSelectSearchComboBoxExample), new PropertyMetadata(null));
+
public MultiSelectSearchComboBoxExample()
{
InitializeComponent();
@@ -19,11 +37,11 @@ public MultiSelectSearchComboBoxExample()
private void MultiSelectSearchComboBoxExample_Loaded(object sender, RoutedEventArgs e)
{
- var list = new List();
- for (int i = 0; i < 10; i++)
- list.Add(i.ToString());
- MyMultiSelectionSearchComboBox2.ItemsSource = list;
- MyMultiSelectionSearchComboBox2.SelectedItems = list.Skip(3).ToList();
+ //var list = new List();
+ //for (int i = 0; i < 10; i++)
+ // list.Add(i.ToString());
+ //MyMultiSelectionSearchComboBox2.ItemsSource = list;
+ //MyMultiSelectionSearchComboBox2.SelectedItems = list.Skip(3).ToList();
var list2 = new List();
list2.Add(new UserInfo() { ID = "0", Name = "343DST.com" });
@@ -32,11 +50,19 @@ private void MultiSelectSearchComboBoxExample_Loaded(object sender, RoutedEventA
list2.Add(new UserInfo() { ID = "3", Name = "josh.peng" });
MyMultiSelectionSearchComboBox3.ItemsSource = list2;
MyMultiSelectionSearchComboBox3.SelectedItems = list2.Where(x => x.ID == "1" || x.ID == "3").ToList();
+
+ ItemsSource = new ObservableCollection(list2);
+ SelectedItems = new ObservableCollection(list2.Where(x => x.ID == "1" || x.ID == "3"));
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
- WPFDevelopers.Controls.MessageBox.Show($"{MyMultiSelectionSearchComboBox2.Text} \r\n总共选中:{MyMultiSelectionSearchComboBox2.SelectedItems.Count} 条","选中内容",MessageBoxButton.OK,MessageBoxImage.Information);
+ WPFDevelopers.Controls.MessageBox.Show($"{MyMultiSelectionSearchComboBox2.Text} \r\n总共选中:{SelectedItems.Count} 条", "选中内容", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
+ private void BtnAdd_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ ItemsSource.Add(new UserInfo() { ID = "4", Name = "OpenAI.com" });
}
}
public class UserInfo