From 4a263c4faa1e5ed3a94f1f8900bce342c230f28a Mon Sep 17 00:00:00 2001 From: Nicolas Musset Date: Sat, 23 Mar 2024 16:25:29 +0100 Subject: [PATCH] [Presentation] Fix issue with binding quantum nodes when associated name is not found (#2195) Note: the solution is rather hackish at the moment. To be revisited once we have an Avalonia version. Should we then introduce a service for setting/retrieving the Unset value --- sources/editor/Stride.Core.Assets.Editor/Module.cs | 2 ++ .../ViewModels/NodeViewModel.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sources/editor/Stride.Core.Assets.Editor/Module.cs b/sources/editor/Stride.Core.Assets.Editor/Module.cs index a0d5b75427..3fddb13d3f 100644 --- a/sources/editor/Stride.Core.Assets.Editor/Module.cs +++ b/sources/editor/Stride.Core.Assets.Editor/Module.cs @@ -17,6 +17,8 @@ public static void Initialize() AssetsPlugin.RegisterPlugin(typeof(CoreAssetsEditorPlugin)); // Initialize translation TranslationManager.Instance.RegisterProvider(new GettextTranslationProvider()); + // HACK + Presentation.Quantum.ViewModels.NodeViewModel.UnsetValue = System.Windows.DependencyProperty.UnsetValue; } } } diff --git a/sources/presentation/Stride.Core.Presentation.Quantum/ViewModels/NodeViewModel.cs b/sources/presentation/Stride.Core.Presentation.Quantum/ViewModels/NodeViewModel.cs index dcd0e387c2..2518786374 100644 --- a/sources/presentation/Stride.Core.Presentation.Quantum/ViewModels/NodeViewModel.cs +++ b/sources/presentation/Stride.Core.Presentation.Quantum/ViewModels/NodeViewModel.cs @@ -47,6 +47,8 @@ internal class DifferentValuesObject { public readonly string Name = "DifferentV public static readonly object DifferentValues = new DifferentValuesObject(); + public static object UnsetValue; + static NodeViewModel() { typeof(NodeViewModel).GetProperties().Select(x => x.Name).ForEach(x => ReservedNames.Add(x)); @@ -317,7 +319,7 @@ public object GetAssociatedData(string name) public object GetDynamicObject(string name) { name = EscapeName(name); - return GetChild(name) ?? GetCommand(name) ?? GetAssociatedData(name); + return GetChild(name) ?? GetCommand(name) ?? GetAssociatedData(name) ?? UnsetValue; } ///