diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-12 20:38:57 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-12 20:38:57 +0200 |
| commit | 14e4bd850fa6730eecd7d15bd7044f364b41c986 (patch) | |
| tree | 4e1945a18def6d1c91f239b2b4dbf6e11c0d51db /Software/Visual_Studio/Tango.SharedUI | |
| parent | 775f0015321f91aa5be3aca079e289e89d4719f5 (diff) | |
| download | Tango-14e4bd850fa6730eecd7d15bd7044f364b41c986.tar.gz Tango-14e4bd850fa6730eecd7d15bd7044f364b41c986.zip | |
Working on data store view.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs | 24 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs | 13 |
2 files changed, 32 insertions, 5 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; diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs index c551f7d49..5c725e524 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs @@ -10,6 +10,17 @@ namespace Tango.SharedUI.Converters { public class EnumToItemsSourceConverter : IValueConverter { + public class EnumValue + { + public Object Value { get; set; } + public String DisplayName { get; set; } + + public override string ToString() + { + return DisplayName; + } + } + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Type result = value as Type; @@ -20,7 +31,7 @@ namespace Tango.SharedUI.Converters } else { - return Enum.GetValues(result).Cast<object>().Select(e => new { Value = e, DisplayName = (e as Enum).ToDescription() }).ToList(); + return Enum.GetValues(result).Cast<object>().Select(e => new EnumValue() { Value = e, DisplayName = (e as Enum).ToDescription() }).ToList(); } } |
