Skip to content

Commit

Permalink
fix: Adjust ContentPresenter automatic propagation
Browse files Browse the repository at this point in the history
Conditionally disables TemplatedParent propagation when the TemplatedParent itself is already in the visual tree.

(cherry picked from commit 8ad591f)
  • Loading branch information
jeromelaban authored and mergify[bot] committed Sep 19, 2024
1 parent ea600f7 commit 27a84ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ public void Init()
_testsResources = new TestsResources();
}

[TestMethod]
[RunsOnUIThread]
[DataRow(typeof(Grid))]
[DataRow(typeof(StackPanel))]
[DataRow(typeof(Border))]
[DataRow(typeof(ContentPresenter))]
public async Task When_SelfLoading(Type type)
{
var control = (FrameworkElement)Activator.CreateInstance(type);

control.Width = 200;
control.Height = 200;

await UITestHelper.Load(control);
}

[TestMethod]
public async Task When_Binding_Within_Control_Template()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,9 @@ protected override void OnApplyTemplate()
#if ANDROID || __IOS__
&& this is not NativeCommandBarPresenter // Uno specific: NativeCommandBarPresenter breaks if you inherit from the TP
#endif
// Uno Specific: Workaround to avoid creating a circular reference when TemplatedParent
// is incorrectly inherited. See https://github.com/unoplatform/uno/issues/17470.
&& !pTemplatedParent.IsLoaded
)
{
// bool needsRefresh = false;
Expand Down

0 comments on commit 27a84ae

Please sign in to comment.