XAMLMarkupExtensions: NestedMarkupExtension doesn't work properly anymore..
Hi,
I’m using WPFLocalizeExtension which again uses XAMLMarkupExtensions, recently I switched to a new version of WPFLocalizeExtension which then again pulled in the latest XAMLMarkupExtensions v1.3.0.
Now I’ve the problem that one of their extensions (LocText) doesn’t work properly with nesting anymore. See this sample project.
In that sample project I use LocText nested in LocText and that worked fine with v3.0.1 of WPFLocalizeExtension and XAMLMarkupExtensions but with the latest versions it doesn’t anymore. After debugging a bit I figured that it’s enough to switch XAMLMarkupExtensions to v1.3.0 while still using WPFLocalizeExtension at v3.0.1 to run into this problem.
After further debugging I found out that the change made with this commit leads to the problem.
Now is this commit correct for what it should do or is IsConnected returning the correct result?! Ok why am I asking this question?! Lets have a look at the following line of the above mentioned sample project:
<Button Content="{lex:LocText StringFormatTest,
FormatSegment1={lex:LocText StringFormat1},
FormatSegment2={lex:LocText StringFormat2}}" />
So we’ve Content as the EndPoint, LocText StringFormatTest is nested inside it, LocText StringFormat1 and LocText StringFormat2 are both nested inside LocText StringFormatTest.
Now if I debug I see that in NestedMarkupExtensions ProvideValue function the LocText StringFormat1 object is added as a listener to NestedMarkupExtension.EndpointReachedEvent and after that I would expect that LocText StringFormat2 object is added as a listener too.
Of course that is done but through the change of the IsConnected check it removes the weakreference of LocText StringFormat1 object first and so LocText StringFormat1 wouldn’t get notified when the EndpointReachedEvent gets fired.
And the next thing that happens is that LocText StringFormat2 gets removed too as in a last step LocText StringFormatTest object is added as a listener and again the IsConnected check returns false which leads to the removal of LocText StringFormat2 object as a listener.
As LocText StringFormatTest is an Endpoint and StringFormat1 + StringFormat2 aren’t but there TargetObject is StringFormatTest, they should get informed about the EndpointReached event or am I wrong?
— EDIT —
Shouldn’t IsConnected return true too if the listeners EndPoint and the EndPoint of the already added listeners is equal or shouldn’t it at least be consindered as a valid result if they aren’t connected to the same sub property?!
Or in case IsConnected is working as desired shouldn’t at least the check to remove the tested target as an EndPointReachedEvent listener get reworked?!
The main problem in this case is that the localization of sub properties (FormatSegment1, FormatSegment2 etc.) won’t work anymore as at the first run the endpoint is null and as the EndPointReachedEvent isn’t invoked for these properties anymore they also won’t get localized anymore as soon as the endpoint was reached.
Previously in v1.2.2 of XAMLMarkupExtensions these segments were localized correctly as soon as the EndPointReached event was fired and so the endpoint was passed. — EDIT —
Sorry for the long text but I hope someone with more knowledge here understands my problem and knows a good solution for it.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (12 by maintainers)
Commits related to this issue
- Merge pull request #14 from DarkCloud14/master Fix for issue #13.. — committed to XAMLMarkupExtensions/XAMLMarkupExtensions by konne 6 years ago
@SeriousM I see ok thanks for the answer, I’ll try my best to get this solved then.