From 7658a8546a9c33a76376dff3ab646f2aceaf0a01 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 17 Jun 2018 19:06:13 +0300 Subject: Working on PPC !!! --- .../Converters/NotificationItemConverter.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/NotificationItemConverter.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Converters') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/NotificationItemConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/NotificationItemConverter.cs new file mode 100644 index 000000000..4e3291b97 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/NotificationItemConverter.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using Tango.PPC.Common.Notifications; + +namespace Tango.PPC.UI.Converters +{ + public class NotificationItemConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + NotificationItem item = value as NotificationItem; + + if (item != null) + { + var view = Activator.CreateInstance(item.ViewType) as FrameworkElement; + + if (view == null) + { + throw new InvalidOperationException("The type " + item.ViewType + " is not a framework element."); + } + + view.DataContext = item; + return view; + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} -- cgit v1.3.1