diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-21 17:45:40 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-21 17:45:40 +0200 |
| commit | a0820b3cde386b4b59c2eb3141493b5e02277485 (patch) | |
| tree | b221e729cb42eeb6e1e3fffd7434dd21e4215d48 /Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs | |
| parent | 229a982d232b818ec0260d25b86451b7726f6061 (diff) | |
| download | Tango-a0820b3cde386b4b59c2eb3141493b5e02277485.tar.gz Tango-a0820b3cde386b4b59c2eb3141493b5e02277485.zip | |
FSE..
Diffstat (limited to 'Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs')
| -rw-r--r-- | Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs index 253843a57..7ed4814d3 100644 --- a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs @@ -18,6 +18,8 @@ namespace Tango.AutoComplete.Editors public class AutoCompleteTextBox : Control { + private ContentControl _partSelectedContent; + #region "Fields" public const string PartEditor = "PART_Editor"; @@ -65,7 +67,7 @@ namespace Tango.AutoComplete.Editors private SuggestionsAdapter _suggestionsAdapter; - + #endregion #region "Constructors" @@ -79,14 +81,22 @@ namespace Tango.AutoComplete.Editors #region "Properties" - + public DataTemplate SelectedItemTemplate + { + get { return (DataTemplate)GetValue(SelectedItemTemplateProperty); } + set { SetValue(SelectedItemTemplateProperty, value); } + } + public static readonly DependencyProperty SelectedItemTemplateProperty = + DependencyProperty.Register("SelectedItemTemplate", typeof(DataTemplate), typeof(AutoCompleteTextBox), new PropertyMetadata(null)); + + public int MaxPopupHeight { - get { return (int) GetValue(MaxPopUpHeightProperty); } - set { SetValue(MaxPopUpHeightProperty, value);} + get { return (int)GetValue(MaxPopUpHeightProperty); } + set { SetValue(MaxPopUpHeightProperty, value); } } - + public BindingEvaluator BindingEvaluator { get { return _bindingEvaluator; } @@ -95,13 +105,13 @@ namespace Tango.AutoComplete.Editors public CharacterCasing CharacterCasing { - get { return (System.Windows.Controls.CharacterCasing) GetValue(CharacterCasingProperty); } - set { SetValue(CharacterCasingProperty, value);} + get { return (System.Windows.Controls.CharacterCasing)GetValue(CharacterCasingProperty); } + set { SetValue(CharacterCasingProperty, value); } } public int MaxLength { - get { return (int) GetValue(DelayProperty); } + get { return (int)GetValue(DelayProperty); } set { SetValue(MaxLengthProperty, value); } } @@ -247,7 +257,8 @@ namespace Tango.AutoComplete.Editors set { SetValue(WatermarkProperty, value); } } - public Brush SuggestionBackground { + public Brush SuggestionBackground + { get { return (Brush)GetValue(SuggestionBackgroundProperty); } set { SetValue(SuggestionBackgroundProperty, value); } @@ -267,6 +278,22 @@ namespace Tango.AutoComplete.Editors { act._isUpdatingText = true; act.Editor.Text = act.BindingEvaluator.Evaluate(e.NewValue); + Keyboard.ClearFocus(); + + if (act._partSelectedContent != null) + { + if (act.SelectedItem == null) + { + act._partSelectedContent.Visibility = Visibility.Collapsed; + act.Editor.Foreground = Application.Current.Resources["FSE_PrimaryForegroundBrush"] as Brush; + } + else + { + act._partSelectedContent.Visibility = Visibility.Visible; + act.Editor.Foreground = Brushes.Transparent; + } + } + act._isUpdatingText = false; } } @@ -279,7 +306,7 @@ namespace Tango.AutoComplete.Editors listBox.ScrollIntoView(listBox.SelectedItem); } - + public override void OnApplyTemplate() { _isUpdatingText = true; @@ -289,6 +316,7 @@ namespace Tango.AutoComplete.Editors Editor = Template.FindName(PartEditor, this) as TextBox; Popup = Template.FindName(PartPopup, this) as Popup; ItemsSelector = Template.FindName(PartSelector, this) as Selector; + _partSelectedContent = Template.FindName("PART_SelectedContent", this) as ContentControl; BindingEvaluator = new BindingEvaluator(new Binding(DisplayMember)); if (Editor != null) |
