Пример #1
0
        private static void OnSourcePropertyChanged(DependencyObject d,
                                                    DependencyPropertyChangedEventArgs e)
        {
            AutoComplete ac = EnsureInstance((Control)d);

            ac.ViewSource.Source = e.NewValue;
        }
Пример #2
0
 private void OnCollectionViewSourceFilter(object sender, FilterEventArgs e)
 {
     if (AutoComplete.GetImplicitItemsFilter(controlUnderAutocomplete.Control) == ImplicitItemsFilter.Enabled)
     {
         var iho = e.Item as AutoComplete.IHaveAnOpinionOnFilter;
         AutoCompleteFilterPathCollection filterPaths = GetAutoCompleteFilterProperty();
         if (iho != null)
         {
             e.Accepted = iho.Match(controlUnderAutocomplete.Text);
         }
         else if (filterPaths != null)
         {
             Type t = e.Item.GetType();
             foreach (string autoCompleteProperty in filterPaths)
             {
                 PropertyInfo info  = t.GetProperty(autoCompleteProperty);
                 object       value = info.GetValue(e.Item, null);
                 if (TextBoxStartsWith(value))
                 {
                     e.Accepted = true;
                     return;
                 }
             }
             e.Accepted = false;
         }
         else
         {
             e.Accepted = TextBoxStartsWith(e.Item);
         }
     }
     else
     {
         e.Accepted = true;
     }
 }
Пример #3
0
        private static AutoComplete EnsureInstance(Control ctrl)
        {
            var ac = ( AutoComplete )ctrl.GetValue(AutoComplete.AutoCompleteInstance);

            if (ac == null)
            {
                ac = new AutoComplete(ctrl);
                //ac.SetControl( ctrl );
                ctrl.SetValue(AutoCompleteInstancePropertyKey, ac);
            }

            return(ac);
        }
Пример #4
0
		private static AutoComplete EnsureInstance( Control ctrl )
		{
			var ac = ( AutoComplete )ctrl.GetValue( AutoComplete.AutoCompleteInstance );
			if( ac == null )
			{
				ac = new AutoComplete( ctrl );
				//ac.SetControl( ctrl );
				ctrl.SetValue( AutoCompleteInstancePropertyKey, ac );
			}

			return ac;
		}
Пример #5
0
        private static void OnItemTemplatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AutoComplete ac = EnsureInstance(( Control )d);

            ac.ListBox.ItemTemplate = ( DataTemplate )e.NewValue;
        }