Enable multiline editing of string values in propertygrids
This commit is contained in:
@@ -16,6 +16,7 @@ namespace Torch.Views
|
|||||||
public bool Enabled = true;
|
public bool Enabled = true;
|
||||||
public bool Visible = true;
|
public bool Visible = true;
|
||||||
public bool ReadOnly = false;
|
public bool ReadOnly = false;
|
||||||
|
public Type EditorType = null;
|
||||||
|
|
||||||
public DisplayAttribute()
|
public DisplayAttribute()
|
||||||
{ }
|
{ }
|
||||||
|
@@ -145,6 +145,11 @@ namespace Torch.Views
|
|||||||
grid.Children.Add(text);
|
grid.Children.Add(text);
|
||||||
|
|
||||||
FrameworkElement valueControl;
|
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)
|
if (property.GetSetMethod() == null || descriptor?.ReadOnly == true)
|
||||||
{
|
{
|
||||||
valueControl = new TextBlock();
|
valueControl = new TextBlock();
|
||||||
@@ -211,11 +216,21 @@ namespace Torch.Views
|
|||||||
|
|
||||||
valueControl = button;
|
valueControl = button;
|
||||||
}
|
}
|
||||||
else if (propertyType.IsPrimitive || propertyType == typeof(string))
|
else if (propertyType.IsPrimitive)
|
||||||
{
|
{
|
||||||
valueControl = new TextBox();
|
valueControl = new TextBox();
|
||||||
valueControl.SetBinding(TextBox.TextProperty, property.Name);
|
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
|
else
|
||||||
{
|
{
|
||||||
var button = new Button
|
var button = new Button
|
||||||
|
Reference in New Issue
Block a user