diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index c4ed67d5ddff..8f2f95603b4c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -1964,8 +1964,8 @@ void writeEvent(string ownerPrefix) // use the WeakReferenceProvider to get a self reference to avoid adding the cost of the // creation of a WeakReference. // - writer.AppendLineInvariant($"var {member.Value}_That = ({eventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;"); - writer.AppendLineInvariant($"{closureName}.{member.Member.Name} += ({parms}) => ({member.Value}_That.Target as {_className.className}).{member.Value}({parms});"); + writer.AppendLineInvariant($"var {member.Member.Name}_{member.Value}_That = ({eventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;"); + writer.AppendLineInvariant($"{closureName}.{member.Member.Name} += ({parms}) => ({member.Member.Name}_{member.Value}_That.Target as {_className.className}).{member.Value}({parms});"); } else { diff --git a/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml b/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml index baf7969caff9..525587a42ee0 100644 --- a/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml +++ b/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml @@ -8,6 +8,6 @@ d:DesignHeight="300" d:DesignWidth="400"> -