diff --git a/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs b/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs index a0c75000..638afc8b 100644 --- a/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs +++ b/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs @@ -1210,7 +1210,7 @@ void WriteEnsureImageLoadingStarted(CodeBuilder builder) builder.WriteLine("if (!m_isImageLoadingStarted)"); builder.OpenScope(); builder.WriteLine("m_isImageLoadingStarted = true;"); - builder.WriteLine($"TypedEventHandler eventHandler{{ this, &{_sourceClassName}::HandleLoadCompleted }};"); + builder.WriteLine($"TypedEventHandler eventHandler{{ get_weak(), &{_sourceClassName}::HandleLoadCompleted }};"); foreach (var n in SourceInfo.LoadedImageSurfaces) {