Using LocProxy does not display any text in preview
DiegoBM opened this issue · 10 comments
I'm using LocProxy in order to bind the Content of a Label to a Key that comes from a window property. During run-time everything works fine, it displays the default value of the property upon run, and it will change the localised text when the key changes. The problem is that the preview mode will display as empty. All the other localised elements are working fine on preview, it's just the LocProxy values the ones that come as empty.
This is my xaml for the binding:
<lex:LocProxy x:Name="LocProxySessionLabel" Source="{Binding ElementName=ApplicationWindow, Path=OpenSessionLabelKey}" />
<Label x:Name="SessionLabel" Content="{Binding ElementName=LocProxySessionLabel, Path=Result, TargetNullValue='Test'}" Margin="10,2,10,0" VerticalAlignment="Top"/>
Is that the intended behaviour of LocProxy? To not display anything.
I can still leverage the FallbackValue of the LocProxy binding in order to at least display a "Key: Something" string, but ideally I'd like to see the translated value on the Preview as well
Hi @DiegoBM
this is at least in my opinion not the intention. I will try to have a look next week.
Thank you @konne, that would be my understanding as well. I hope you find the root cause :)
Thank you for your answer @konne, I did not explicitly add any specific DataContext. Since it all worked fine for the standard lex:Loc, I assumed that I didn't need to do anything differently for locProxy. I added the FallbackValues to the locProxies and that at least displayed a fallback value for the controls bound to those locProxies
@DiegoBM lex:Loc is pointing to the resources, they are automatically available. LocProxy sets a Binding like an regular Binding to a property in the DataContex. Please test if this is working with setting a designtime
mc:Ignorable="d" d:DataContext="{d:DesignInstance Type=local:MyView, IsDesignTimeCreatable=False}"
datacontext please close. If you search for designtime datacontext wpf you find a lot of examples
@konne I did as instructed (of course replacing the view name) and although everything compiled well, I still didn't get the translations at design time. I tried resetting the designer process as well as restarting Visual Studio, to no avail
@DiegoBM
I still don't understand your Suisse. I have added explicit this use case to the HelloWorldWPF sample. And it is perfect working with lex:LocProxy
this commit 1cb14aa
Note: We will introduce direct Binding support for lex:loc so that you don't need LocProxy anymore. You can also find already an examples in this version.
I will close this issue for now. If you still see an issue please add an PR for example to the HelloWorldWPF sample to reproduce your issue.