Let's not require people to press a button to edit primitives

This commit is contained in:
Brant Martin
2018-02-11 23:22:30 -05:00
parent c32badb750
commit a4927030d7

View File

@@ -181,7 +181,7 @@ namespace Torch.Views
{
Content = "Edit Collection"
};
button.SetBinding(Button.DataContextProperty, $"{property.Name}");
button.SetBinding(Button.DataContextProperty, property.Name);
var gt = propertyType.GetGenericArguments()[0];
@@ -197,11 +197,21 @@ namespace Torch.Views
valueControl = button;
}
else
else if (propertyType.IsPrimitive || propertyType == typeof(string))
{
valueControl = new TextBox();
valueControl.SetBinding(TextBox.TextProperty, property.Name);
}
else
{
var button = new Button
{
Content = "Edit Object"
};
button.SetBinding(Button.DataContextProperty, property.Name);
button.Click += (sender, args) => EditObject(((Button)sender).DataContext);
valueControl = button;
}
valueControl.Margin = new Thickness(3);
valueControl.VerticalAlignment = VerticalAlignment.Center;
@@ -241,6 +251,11 @@ namespace Torch.Views
new ObjectCollectionEditor().Edit(c, title);
}
private void EditObject(object o, string title = "Edit Object")
{
new ObjectEditor().Edit(o, title);
}
private void UpdateFilter(object sender, TextChangedEventArgs e)
{
var filterText = ((TextBox)sender).Text;