Skip to content

Commit

Permalink
fix(resources): Don't reevaluate all resources on all measure
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jan 11, 2025
1 parent cdf4548 commit 27b8530
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public partial class FrameworkElement
private readonly static IEventProvider _trace = Tracing.Get(FrameworkElement.TraceProvider.Id);

private bool m_firedLoadingEvent;
private bool m_requiresResourcesUpdate = true;

private const double SIZE_EPSILON = 0.05d;
private readonly Size MaxSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
Expand Down Expand Up @@ -282,11 +283,12 @@ private void InnerMeasureCore(Size availableSize)
//if (!bInLayoutTransition)
{
// Templates should be applied here.
InvokeApplyTemplate(out _);
InvokeApplyTemplate(out var addedVisual);

// TODO: BEGIN Uno specific
if (this is Control thisAsControl)
if (m_requiresResourcesUpdate && this is Control thisAsControl)
{
m_requiresResourcesUpdate = false;
// Update bindings to ensure resources defined
// in visual parents get applied.
this.UpdateResourceBindings();
Expand Down Expand Up @@ -991,6 +993,10 @@ internal override void EnterImpl(EnterParams @params, int depth)
{
var core = this.GetContext();

// ---------- Uno-specific BEGIN ----------
m_requiresResourcesUpdate = true;
// ---------- Uno-specific END ----------

//if (@params.IsLive && @params.CheckForResourceOverrides == false)
//{
// var resources = GetResourcesNoCreate();
Expand Down Expand Up @@ -1066,7 +1072,7 @@ internal override void LeaveImpl(LeaveParams @params)
// of properties that are marked with MetaDataPropertyInfoFlags::IsSparse and MetaDataPropertyInfoFlags::IsVisualTreeProperty
// are entered as well.
// The property we currently know it has an effect is Resources
if (Resources is not null)
if (TryGetResources() is not null)
{
// Using ValuesInternal to avoid Enumerator boxing
foreach (var resource in Resources.ValuesInternal)
Expand Down

0 comments on commit 27b8530

Please sign in to comment.