Skip to content

Commit

Permalink
perf: Initialize UIElement.KeyboardAcceleratorsProperty lazily
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed May 19, 2021
1 parent 9c01d26 commit 61c4223
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Uno.UI/UI/Xaml/UIElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ public static void RegisterAsScrollPort(UIElement element)

private void Initialize()
{
this.SetValue(KeyboardAcceleratorsProperty, new List<KeyboardAccelerator>(0), DependencyPropertyValuePrecedences.DefaultValue);
this.RegisterDefaultValueProvider(OnGetDefaultValue);
}

private bool OnGetDefaultValue(DependencyProperty property, out object defaultValue)
{
if (property == KeyboardAcceleratorsProperty)
{
defaultValue = new List<KeyboardAccelerator>(0);
return true;
}

defaultValue = null;
return false;
}

public Vector2 ActualSize => new Vector2((float)GetActualWidth(), (float)GetActualHeight());
Expand Down

0 comments on commit 61c4223

Please sign in to comment.