Esempio n. 1
0
				static void SelectedItem_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
				{
					ComboBoxAdaptor adapter = (ComboBoxAdaptor)d;
					if (adapter.ItemsSource != null)
					{
						//If SelectedItem is changing from the Source (which we can tell by checking if the
						//ComboBox.SelectedItem is already set to the new value), trigger Adapt() so that we
						//throw out any items that are not in ItemsSource.
						object adapterValue = (e.NewValue ?? adapter.NullItem);
						object comboboxValue = (adapter.ComboBox.SelectedItem ?? adapter.NullItem);
						if (!object.Equals(adapterValue, comboboxValue))
						{
							adapter.Adapt();
							adapter.ComboBox.SelectedItem = e.NewValue;
						}
						//If the NewValue is not in the CollectionView (and therefore not in the ComboBox)
						//trigger an Adapt so that it will be added.
						else if (e.NewValue != null && !adapter.CollectionView.Contains(e.NewValue))
						{
							adapter.Adapt();
						}
					}
				}
Esempio n. 2
0
        static void AllowNull_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ComboBoxAdaptor adapter = (ComboBoxAdaptor)d;

            adapter.Adapt();
        }
Esempio n. 3
0
        static void ItemsSource_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ComboBoxAdaptor adapter = (ComboBoxAdaptor)d;

            adapter.Adapt();
        }