diff --git a/Torch/Views/DisplayAttribute.cs b/Torch/Views/DisplayAttribute.cs index db75289..9dda943 100644 --- a/Torch/Views/DisplayAttribute.cs +++ b/Torch/Views/DisplayAttribute.cs @@ -12,22 +12,25 @@ namespace Torch.Views public string Description; public string ToolTip; public string GroupName; - public int? Order; - public bool? Enabled; - public bool? Visible; - public bool? ReadOnly; + public int Order; + public bool Enabled = true; + public bool Visible = true; + public bool ReadOnly = false; public DisplayAttribute() { } public static implicit operator DisplayAttribute(System.ComponentModel.DataAnnotations.DisplayAttribute da) { + if (da == null) + return null; + return new DisplayAttribute() { Name = da.GetName(), Description = da.GetDescription(), GroupName = da.GetGroupName(), - Order = da.GetOrder() + Order = da.GetOrder() ?? 0 }; } } diff --git a/Torch/Views/PropertyGrid.xaml.cs b/Torch/Views/PropertyGrid.xaml.cs index 3168bd7..4d44340 100644 --- a/Torch/Views/PropertyGrid.xaml.cs +++ b/Torch/Views/PropertyGrid.xaml.cs @@ -110,7 +110,7 @@ namespace Torch.Views c.Value.Sort((a, b) => { - var c1 = descriptors[a]?.Order?.CompareTo(descriptors[b]?.Order); + var c1 = descriptors[a]?.Order.CompareTo(descriptors[b]?.Order); if (c1.HasValue && c1.Value != 0) return c1.Value; return string.Compare((descriptors[a]?.Name ?? a.Name), descriptors[b]?.Name ?? b.Name, StringComparison.Ordinal); @@ -138,8 +138,8 @@ namespace Torch.Views text.Margin = new Thickness(3); text.Tag = $"{text.Text}: {descriptor?.Description}"; text.IsMouseDirectlyOverChanged += Text_IsMouseDirectlyOverChanged; - if (descriptor?.Enabled == false) - text.IsEnabled = false; + //if (descriptor?.Enabled == false) + // text.IsEnabled = false; grid.Children.Add(text); FrameworkElement valueControl;