public override void OnApplyTemplate() { base.OnApplyTemplate(); _clearButton = GetTemplateChild("PART_ClearButton") as Button; if (_clearButton is null) { throw Log.ErrorAndCreateException <InvalidOperationException>("Can't find template part 'PART_ClearButton'"); } _clearButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _clearFilter); this.AttachBehavior <UpdateBindingOnTextChanged>(); this.AttachBehavior <SelectTextOnFocus>(); _autoCompletion = this.AttachBehavior <AutoCompletion>(); UpdateAutoCompletion(); var serviceEventArg = new InitializingAutoCompletionServiceEventArgs(); OnInitializingAutoCompletionService(serviceEventArg); var autoCompletionService = serviceEventArg.AutoCompletionService; if (autoCompletionService == null) { return; } //Hack var autoCompletionServiceFieldInfo = _autoCompletion.GetType().GetField("_autoCompletionService", BindingFlags.Instance | BindingFlags.NonPublic); if (autoCompletionServiceFieldInfo != null) { autoCompletionServiceFieldInfo.SetValue(_autoCompletion, autoCompletionService); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); SetCurrentValue(AccentColorBrushProperty, TryFindResource("AccentColorBrush") as SolidColorBrush); _clearButton?.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, null); _clearButton = (Button)GetTemplateChild("PART_ClearButton"); _clearButton?.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _clearFilter); _filterTextBox = GetTemplateChild("PART_FilterTextBox") as TextBox; if (_filterTextBox is null) { throw Log.ErrorAndCreateException <InvalidOperationException>($"Can't find template part 'PART_FilterTextBox'"); } var serviceEventArg = new InitializingAutoCompletionServiceEventArgs(); OnInitializingAutoCompletionService(serviceEventArg); var autoCompletionService = serviceEventArg.AutoCompletionService; if (autoCompletionService == null) { return; } var autoCompletion = Interaction.GetBehaviors(_filterTextBox).OfType <AutoCompletion>().FirstOrDefault(); if (autoCompletion == null) { return; } var autoCompletionServiceFieldInfo = autoCompletion.GetType().GetField("_autoCompletionService", BindingFlags.Instance | BindingFlags.NonPublic); if (autoCompletionServiceFieldInfo != null) { autoCompletionServiceFieldInfo.SetValue(autoCompletion, autoCompletionService); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); SetCurrentValue(AccentColorBrushProperty, TryFindResource("AccentColorBrush") as SolidColorBrush); if (_clearButton != null) { _clearButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, null); } _clearButton = (Button)GetTemplateChild("PART_ClearButton"); if (_clearButton != null) { _clearButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _clearFilter); } _filterTextBox = (TextBox)GetTemplateChild("PART_FilterTextBox"); var serviceEventArg = new InitializingAutoCompletionServiceEventArgs(); OnInitializingAutoCompletionService(serviceEventArg); var autoCompletionService = serviceEventArg.AutoCompletionService; if (autoCompletionService != null) { var autoCompletion = Interaction.GetBehaviors(_filterTextBox).OfType <AutoCompletion>().FirstOrDefault(); if (autoCompletion != null) { var autoCompletionServiceFieldInfo = autoCompletion.GetType().GetField("_autoCompletionService", BindingFlags.Instance | BindingFlags.NonPublic); if (autoCompletionServiceFieldInfo != null) { autoCompletionServiceFieldInfo.SetValue(autoCompletion, autoCompletionService); } } } }
protected virtual void OnInitializingAutoCompletionService(InitializingAutoCompletionServiceEventArgs e) { InitializingAutoCompletionService?.Invoke(this, e); }