diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-06 21:10:57 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-06 21:10:57 +0200 |
| commit | 36bde2234f457f4bb93caf6d1f2e47ddf895be39 (patch) | |
| tree | 5f566164a3f0cda4fc329151058354893263c5c6 /Software/Visual_Studio/Tango.SharedUI/Converters | |
| parent | cc707ae8bd0100449e9e8fb68e09dae144421b54 (diff) | |
| download | Tango-36bde2234f457f4bb93caf6d1f2e47ddf895be39.tar.gz Tango-36bde2234f457f4bb93caf6d1f2e47ddf895be39.zip | |
Added new PID and heaters to hw, diagnostics and tech.
Implemented proper sorting on hw version and tech board. (DB CHANGE!)
Related Work Items: #1595
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Converters')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs new file mode 100644 index 000000000..a2363575a --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/ObservableCollectionToViewSourceConverter.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.SharedUI.Converters +{ + public class ObservableCollectionToViewSourceConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + String sortMember = parameter != null ? parameter.ToString() : null; + IList list = value as IList; + if (list != null) + { + var view = CollectionViewSource.GetDefaultView(list); + view.SortDescriptions.Clear(); + + //Delay because the DataGrid clears the sort description after source change. + Task.Factory.StartNew(() => + { + Thread.Sleep(10); + + Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + view.SortDescriptions.Add(new SortDescription(sortMember, ListSortDirection.Ascending)); + view.Refresh(); + })); + }); + return view; + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} |
