You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$"({member.Member.Name}_{sanitizedEventTarget}_That.Target as {XamlConstants.Types.FrameworkElement})?.DataContext as {dataTypeSymbol.GetFullyQualifiedTypeIncludingGlobal()}",
3687
-
3688
-
// Use of __rootInstance is required to get the top-level DataContext, as it may be changed
3689
-
// in the current visual tree by the user.
3690
-
$"(__rootInstance as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference",
(true,_)=>method.declaringType.GetFullyQualifiedTypeIncludingGlobal(),// If the method is static, the target onto which the method should be invoked is the declaringType itself
3657
+
(_,true)=>$"((target.Target as {XamlConstants.Types.FrameworkElement})?.DataContext as {targetType.GetFullyQualifiedTypeIncludingGlobal()})?",
3658
+
_ =>$"(target.Target as {targetType.GetFullyQualifiedTypeIncludingGlobal()})?"
3659
+
};
3712
3660
3713
3661
varhandler=RegisterChildSubclass(
3714
3662
$"{parentApply}_{member.Member.Name}_Handler",
@@ -3717,7 +3665,7 @@ public class {{name}}(global::Uno.UI.DataBinding.ManagedWeakReference target)
3717
3665
{
3718
3666
public void Invoke({{parametersWithType.JoinBy(", ")}})
3719
3667
{
3720
-
(target.Target as {{_xClassName}})?.{{eventTarget}}({{(targetMethodHasParameters?parameters.JoinBy(", "):"")}});
@@ -3736,15 +3684,13 @@ public void Invoke({{parametersWithType.JoinBy(", ")}})
3736
3684
return;
3737
3685
}
3738
3686
3739
-
{{componentDefinition.MemberName}}.{{member.Member.Name}} += new {{handler}}({{targetContext.weakReference}}).Invoke;
3687
+
{{componentDefinition.MemberName}}.{{member.Member.Name}} += new {{handler}}({{targetInstanceWeakRef}}).Invoke;
3740
3688
__is{{name}}d = true;
3741
3689
}
3742
3690
"""));
3743
3691
}
3744
3692
else
3745
3693
{
3746
-
EnsureXClassName();
3747
-
3748
3694
//
3749
3695
// Generate a sub-class that uses a weak ref, so the owner is not being held onto by the delegate.
3750
3696
// We can use the WeakReferenceProvider to get a self reference to avoid adding the cost of the
@@ -3762,11 +3708,60 @@ public void Invoke({{parametersWithType.JoinBy(", ")}})
3762
3708
}
3763
3709
}
3764
3710
"""));
3765
-
writer.AppendLineIndented($"var {member.Member.Name}_Handler = new {subClass}(({eventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference);");
3711
+
writer.AppendLineIndented($"var {member.Member.Name}_Handler = new {subClass}(({targetInstance} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference);");
3766
3712
writer.AppendLineIndented($"/* second level */ {closureName}.{member.Member.Name} += {member.Member.Name}_Handler.Invoke;");
0 commit comments