forked from snoopwpf/snoopwpf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SnoopParameterInformationTemplateSelector.cs
43 lines (40 loc) · 1.57 KB
/
SnoopParameterInformationTemplateSelector.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// (c) Copyright Cory Plotts.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http:https://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
namespace Snoop.MethodsTab
{
public class SnoopParameterInformationTemplateSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
FrameworkElement element = container as FrameworkElement;
if (element == null)
return null;
SnoopParameterInformation snoopParameterInfo = item as SnoopParameterInformation;
//if (snoopParameterInfo.TypeConverter.GetType() == typeof(TypeConverter))
if (snoopParameterInfo.IsEnum || snoopParameterInfo.ParameterType.Equals(typeof(bool)))
{
return element.FindResource("EnumParameterTemplate") as DataTemplate;
}
if (snoopParameterInfo.ParameterType.Equals(typeof(DependencyProperty)))
{
return element.FindResource("DependencyPropertyTemplate") as DataTemplate;
}
if (snoopParameterInfo.IsCustom)
{
return element.FindResource("UnknownParameterTemplate") as DataTemplate;
}
else
{
return element.FindResource("DefaultParameterTemplate") as DataTemplate;
}
}
}
}