From 61c4223a6210c9cf36366b0d3dbfc77cdfe3f53a Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Tue, 18 May 2021 10:11:35 -0400 Subject: [PATCH] perf: Initialize `UIElement.KeyboardAcceleratorsProperty` lazily --- src/Uno.UI/UI/Xaml/UIElement.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Uno.UI/UI/Xaml/UIElement.cs b/src/Uno.UI/UI/Xaml/UIElement.cs index 8ba3e0f7d6f2..3f4413008ba9 100644 --- a/src/Uno.UI/UI/Xaml/UIElement.cs +++ b/src/Uno.UI/UI/Xaml/UIElement.cs @@ -60,7 +60,19 @@ public static void RegisterAsScrollPort(UIElement element) private void Initialize() { - this.SetValue(KeyboardAcceleratorsProperty, new List(0), DependencyPropertyValuePrecedences.DefaultValue); + this.RegisterDefaultValueProvider(OnGetDefaultValue); + } + + private bool OnGetDefaultValue(DependencyProperty property, out object defaultValue) + { + if (property == KeyboardAcceleratorsProperty) + { + defaultValue = new List(0); + return true; + } + + defaultValue = null; + return false; } public Vector2 ActualSize => new Vector2((float)GetActualWidth(), (float)GetActualHeight());