diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs index 583d7b810..1f2856a32 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs @@ -12,6 +12,7 @@ using System.Windows.Input; using System.Linq; using System.Windows.Media; using System.Windows.Threading; +using Tango.Core.ExtensionMethods; namespace Tango.SharedUI.Controls { @@ -73,6 +74,11 @@ namespace Tango.SharedUI.Controls { IsOpened = false; SelectedItem = _listBox.SelectedItem; + + if (SelectedValuePath.IsNotNullOrEmpty() && SelectedItem != null) + { + SelectedValue = SelectedItem.GetPropertyValueByPath(SelectedValuePath); + } } else if (e.Key == Key.Up && _listBox.SelectedIndex == 0) { @@ -120,6 +126,11 @@ namespace Tango.SharedUI.Controls { IsOpened = false; SelectedItem = _listBox.SelectedItem; + + if (SelectedValuePath.IsNotNullOrEmpty() && SelectedItem != null) + { + SelectedValue = SelectedItem.GetPropertyValueByPath(SelectedValuePath); + } } } } @@ -152,12 +163,17 @@ namespace Tango.SharedUI.Controls if (x != null) { - var prop = x.GetType().GetProperty(SearchProperty, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); - if (prop != null) + if (!String.IsNullOrWhiteSpace(SearchProperty)) { - String propValue = prop.GetValue(x).ToString(); - return propValue.ToLower().Contains(SearchFilter.ToLower()); + var prop = x.GetType().GetProperty(SearchProperty, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); + if (prop != null) + { + String propValue = prop.GetValue(x).ToString(); + return propValue.ToLower().Contains(SearchFilter.ToLower()); + } } + + return x.ToStringSafe().ToLower().Contains(SearchFilter.ToLower()); } return false; |
