From 9a99caabe1a4500604010fe41028e7bbc4d460eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20K=C3=B6nig?= Date: Sat, 25 Nov 2023 18:39:10 +0100 Subject: [PATCH] Some cleanup --- .../_View/_PropertyGrid/PropertyGrid.axaml.cs | 25 +++++++++++++------ src/MessageCommunicator.sln.DotSettings | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/MessageCommunicator.TestGui/_Util/_View/_PropertyGrid/PropertyGrid.axaml.cs b/src/MessageCommunicator.TestGui/_Util/_View/_PropertyGrid/PropertyGrid.axaml.cs index f6ddb7e..356c71f 100644 --- a/src/MessageCommunicator.TestGui/_Util/_View/_PropertyGrid/PropertyGrid.axaml.cs +++ b/src/MessageCommunicator.TestGui/_Util/_View/_PropertyGrid/PropertyGrid.axaml.cs @@ -7,6 +7,7 @@ using Avalonia.Markup.Xaml; using Avalonia.Media; using System.Text; +using Avalonia.Data; using Avalonia.Input; using FirLib.Core.Patterns.Mvvm; @@ -16,11 +17,12 @@ namespace MessageCommunicator.TestGui { public class PropertyGrid : OwnUserControl { - public static readonly StyledProperty SelectedObjectProperty = - AvaloniaProperty.Register( - nameof(SelectedObject), typeof(object), - notifying: OnSelectedObjectChanged); - + public static readonly DirectProperty SelectedObjectProperty = + AvaloniaProperty.RegisterDirect( + nameof(SelectedObject), + propGrid => propGrid.SelectedObject, + (propGrid, val) => propGrid.SelectedObject = val); + public static readonly StyledProperty EditControlFactoryProperty = AvaloniaProperty.Register( nameof(EditControlFactory), @@ -29,15 +31,22 @@ public class PropertyGrid : OwnUserControl public static readonly StyledProperty PropertyContractResolverProperty = AvaloniaProperty.Register( nameof(PropertyContractResolver)); - + private PropertyGridViewModel _propertyGridVM; private Grid _gridMain; private Control? _firstValueRowEditor; + private object? _selectedObject; public object? SelectedObject { - get => this.GetValue(SelectedObjectProperty); - set => this.SetValue(SelectedObjectProperty, value); + get => _selectedObject; + set + { + _selectedObject = value; + + _propertyGridVM.SelectedObject = _selectedObject; + UpdatePropertiesView(); + } } public PropertyGridEditControlFactory? EditControlFactory diff --git a/src/MessageCommunicator.sln.DotSettings b/src/MessageCommunicator.sln.DotSettings index 2d16f08..c59b27a 100644 --- a/src/MessageCommunicator.sln.DotSettings +++ b/src/MessageCommunicator.sln.DotSettings @@ -347,6 +347,7 @@ True 12 + True True True True @@ -360,7 +361,7 @@ True True True - anonymous + True True [120,-22](1604,883)