diff --git a/Torch/Views/DisplayAttribute.cs b/Torch/Views/DisplayAttribute.cs index 9dda943..ba9c043 100644 --- a/Torch/Views/DisplayAttribute.cs +++ b/Torch/Views/DisplayAttribute.cs @@ -16,6 +16,7 @@ namespace Torch.Views public bool Enabled = true; public bool Visible = true; public bool ReadOnly = false; + public Type EditorType = null; public DisplayAttribute() { } diff --git a/Torch/Views/PropertyGrid.xaml.cs b/Torch/Views/PropertyGrid.xaml.cs index 9e0bd39..4549c58 100644 --- a/Torch/Views/PropertyGrid.xaml.cs +++ b/Torch/Views/PropertyGrid.xaml.cs @@ -145,6 +145,11 @@ namespace Torch.Views grid.Children.Add(text); FrameworkElement valueControl; + if (descriptor?.EditorType != null) + { + valueControl = (FrameworkElement)Activator.CreateInstance(descriptor.EditorType); + valueControl.SetBinding(FrameworkElement.DataContextProperty, property.Name); + } if (property.GetSetMethod() == null || descriptor?.ReadOnly == true) { valueControl = new TextBlock(); @@ -211,11 +216,21 @@ namespace Torch.Views valueControl = button; } - else if (propertyType.IsPrimitive || propertyType == typeof(string)) + else if (propertyType.IsPrimitive) { valueControl = new TextBox(); valueControl.SetBinding(TextBox.TextProperty, property.Name); } + else if (propertyType == typeof(string)) + { + var tb = new TextBox(); + tb.TextWrapping = TextWrapping.Wrap; + tb.AcceptsReturn = true; + tb.AcceptsTab = true; + tb.SpellCheck.IsEnabled = true; + tb.SetBinding(TextBox.TextProperty, property.Name); + valueControl = tb; + } else { var button = new Button