Skip to content

Commit

Permalink
feat: TextElement.XamlRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Dec 29, 2022
1 parent c443cdd commit f4fd1b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public bool IsAccessKeyScope
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || false || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.Xaml.XamlRoot XamlRoot
{
Expand Down
29 changes: 29 additions & 0 deletions src/Uno.UI/UI/Xaml/Documents/TextElement.XamlRoot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#nullable enable

using System;
using Uno.UI.DataBinding;
using Uno.UI.Extensions;
using Uno.UI.Xaml.Core;

namespace Windows.UI.Xaml.Documents;

public partial class TextElement
{
private ManagedWeakReference? _visualTreeCacheWeakReference;

/// <summary>
/// Gets or sets the XamlRoot in which this element is being viewed.
/// </summary>
public XamlRoot? XamlRoot
{
get => XamlRoot.GetForElement(this);
set => XamlRoot.SetForElement(this, XamlRoot, value);
}

internal VisualTree? VisualTreeCache
{
get => _visualTreeCacheWeakReference?.IsDisposed == false ?
_visualTreeCacheWeakReference.Target as VisualTree : null;
set => _visualTreeCacheWeakReference = WeakReferencePool.RentWeakReference(this, value);
}
}

0 comments on commit f4fd1b5

Please sign in to comment.