/// <summary> /// Handle the Loaded event of the page. /// </summary> /// <param name="sender">The source object.</param> /// <param name="rea">The event arguments.</param> private void OnLoaded(object sender, RoutedEventArgs rea) { ControlApi.ItemFilter = (prefix, item) => { if (string.IsNullOrEmpty(prefix)) { return(true); } MemberInfoData pme = item as MemberInfoData; if (pme == null) { return(false); } return(pme.Name.ToUpper(CultureInfo.InvariantCulture).Contains(prefix.ToUpper(CultureInfo.InvariantCulture))); }; // Reflect and load data ControlApi.ItemsSource = MemberInfoData.GetSetForType(typeof(AutoCompleteBox)); ControlPicker.ItemsSource = InitializeTypeList(); // Set the changed handlers ControlApi.SelectionChanged += OnApiChanged; ControlPicker.SelectionChanged += OnPickerChanged; // Setup the dictionary converter ControlPicker.ValueMemberBinding = new Binding { Converter = new DictionaryKeyValueConverter <string, Type>() }; }
/// <summary> /// Update the API system. /// </summary> /// <param name="sender">The source object.</param> /// <param name="e">The selection changed event data.</param> private void OnPickerChanged(object sender, SelectionChangedEventArgs e) { if (ControlPicker.SelectedItem == null) { ControlApi.ItemsSource = null; ControlApi.Text = null; IntelliSenseIcon.Content = null; ControlApi.IsEnabled = false; } else { KeyValuePair <string, Type> pair = (KeyValuePair <string, Type>)ControlPicker.SelectedItem; ControlApi.ItemsSource = MemberInfoData.GetSetForType(pair.Value); ControlApi.IsEnabled = true; } }