Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xaml中静态引用后GC时的问题 #17

Open
lolo77777 opened this issue Jan 18, 2025 · 1 comment
Open

xaml中静态引用后GC时的问题 #17

lolo77777 opened this issue Jan 18, 2025 · 1 comment
Assignees

Comments

@lolo77777
Copy link

大佬你好,我在avalonia中用了可以实现动态切换语言,效果很好,非常感谢。
现在有个问题,想请教下,我的view和viewmodel是注册成了瞬态,当他不激活的时候,打算让他释放掉。最近发现引用多语言的view和viewmodel不会被gc释放。想了下是不是多语言的通知订阅问题?如果是的话有没有什么简单的办法可以解除要释放的view里面多语言的订阅呢

@lolo77777
Copy link
Author

暂时用了个笨办法。我改成了在axaml.cs中TextBlockName.Text= I18NExtension.Translate(LangKeys.Property)赋值的办法,修改语言时做了通知重新执行赋值。view失去激活的时候解除通知订阅。view可以正常被gc释放了。
不知道有没有更优化的方法

@feast107 feast107 self-assigned this Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants