Fix custom control type in property grids

This commit is contained in:
Brant Martin
2018-07-02 11:27:43 -04:00
parent 8b08f2b747
commit 736176ce27

View File

@@ -67,8 +67,8 @@ namespace Torch.Views
var properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public); var properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public);
var grid = new Grid(); var grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
var categories = new Dictionary<string, List<PropertyInfo>>(); var categories = new Dictionary<string, List<PropertyInfo>>();
var descriptors = new Dictionary<PropertyInfo, DisplayAttribute>(properties.Length); var descriptors = new Dictionary<PropertyInfo, DisplayAttribute>(properties.Length);
@@ -150,7 +150,7 @@ namespace Torch.Views
valueControl = (FrameworkElement)Activator.CreateInstance(descriptor.EditorType); valueControl = (FrameworkElement)Activator.CreateInstance(descriptor.EditorType);
valueControl.SetBinding(FrameworkElement.DataContextProperty, property.Name); valueControl.SetBinding(FrameworkElement.DataContextProperty, property.Name);
} }
if (property.GetSetMethod() == null || descriptor?.ReadOnly == true) else if (property.GetSetMethod() == null || descriptor?.ReadOnly == true)
{ {
valueControl = new TextBlock(); valueControl = new TextBlock();
var binding = new Binding(property.Name) var binding = new Binding(property.Name)