SettingsCard error when using wpflocalizeextension library
Describe the bug
When using the wpflocalizeextension library for language localization, Xaml errors are found at runtime.
Reproduction
When the above code is run, XAML will report an error. The error message is: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.FrameworkElement', AncestorLevel='1''. BindingExpression:Path=Parent; DataItem=null; target element is 'SettingsCard' (Name=''); target property is 'Parent' (type 'DependencyObject')
It works fine after changing to Header="{Binding Source={lex:Loc SettingPage_杂项}}".
This is a bit strange, because the TextBlock is working fine.
I tried putting SettingsCard at the same level as SettingsExpander, and SettingsCard worked fine again without any errors.
Suggested Solution
No response
Library Version
0.10.0
Operating System
Windows 11
Framework
.NET Framework
Framework Version
8.0
Source of Package
NuGet.org (Package)
Additional Notes
No response
Validations
- [x] Check that there isn't already an issue that reports the same or similar problem.
- [x] Check that this is a bug in the library that should be fixed, not a feature, also this is not about the documentation. (Or please choose the right repo and template.)
- [x] This is one single problem, or a few problems with the same cause. (If you want to report multiple problems, please create one issue for every single problem.)
- [x] You've checked that this problem still exists in the latest version. (Keep in mind that we don't provide any support for old versions.)
- [x] You know that we can't guarantee that we will satisfy your request. This is not really our duty to do everything anyone asks for. Also, you will treat our staff, contributors, and other users with respect and kindness.
- [x] You're sure there's something wrong with the library itself, not how you're using it. (If you are having issues using it and need help, please go to discussion.)
WpfApp.TestDemo.zip This is my test code, please help check it. Thanks a lot
Hi @Tate-Zhang , I tried your test demo and a binding error is indeed raised, however it doesn't seem to be affecting any functionality.
https://github.com/user-attachments/assets/87225afb-f7de-4205-a4e0-fdb47c94737d
In regard to the binding error itself, i think the ParentChangedNotifier (an internal infrastructure for WpfLocalizeExtension) suggests this is related to WpfLocalizeExtension internal workings.
嗨,我尝试了您的测试演示,确实引发了绑定错误,但它似乎不会影响任何功能。
settingsExpanderWpfLocalizeProblem.mp4 关于绑定错误本身,我认为 ParentChangedNotifier(WpfLocalizeExtension 的内部基础结构)表明这与 WpfLocalizeExtension 内部工作有关。
Yes, it doesn't affect any of my functions, it just looks like there are a lot of errors and may affect my handling of real errors
@Tate-Zhang , can u see if #285 works for you ?