blob: 7ecd891a834f65dac8714bf695369db01c0b7d18 (
plain)
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
|
using System.Windows;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Windows
{
internal class ObjectEditorControl
: PropertyEditorControl
{
static ObjectEditorControl()
{
DefaultStyleKeyProperty.OverrideMetadata (typeof(ObjectEditorControl), new FrameworkPropertyMetadata (typeof(ObjectEditorControl)));
}
public ObjectEditorControl()
{
DataContextChanged += OnDataContextChanged;
}
private void OnDataContextChanged (object sender, DependencyPropertyChangedEventArgs e)
{
var vm = e.OldValue as ObjectPropertyViewModel;
if (vm != null)
vm.TypeRequested -= OnTypeRequested;
vm = e.NewValue as ObjectPropertyViewModel;
if (vm != null)
vm.TypeRequested += OnTypeRequested;
}
private void OnTypeRequested (object sender, TypeRequestedEventArgs e)
{
var vm = (ObjectPropertyViewModel)sender;
var panel = this.FindPropertiesHost ();
ITypeInfo type = TypeSelectorWindow.RequestType (panel, vm.AssignableTypes);
e.SelectedType = type;
}
}
}
|