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.
  • Loading branch information
jeromelaban committed Sep 19, 2024
1 parent 3c6f7c5 commit 8ad591f
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 @@ -61,6 +61,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 @@ -662,6 +662,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 8ad591f

Please sign in to comment.