-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Setter & Binding usage with XAMLMarkupExtension 2.0 #271
Comments
Hi, I just saw this issue and I was wondering: should the first case still work if the <Binding Source="{lex:Loc {Binding MyProperty}}" /> I tried it but it seems to give me an empty string instead. My use case is also slightly different because I want the binding for one of the arguments, not the string format, but I guess they are probably handled in the same way. Otherwise, is there a recommended way of achieving that? I could only find a workaround by using a dummy, collapsed framework element (it could be an <Binding ElementName="TheDummyElement" Path="ThePropertyOfTheDummyElementWithTheBinding" /> Other than this, great library so far! |
Hi, good question. I will test this, but the issue here might be that Binding is a MarkupExtension and not a DependencyObject. It can be that the necessary changes are still not in the pre / release. Normally this Binding inside a MarkupExtension is not possible, but karnah and I found together |
Following the example above, I'm trying to change the value of a Setter:
This displays "Key: en" and not the correct string. Also, I would like to be able to set any language (as in Text="{lex:Loc}") @konne Could you provide any help? |
@NiklasMoller, hi! |
@Karnah Thanks! Could you provide an example in code of what you describe? |
@NiklasMoller, hmm, I've checked your case again. It should be enough to set this lines in main window. WPFLocalizeExtension/tests/HelloWorldWPF/MainWindow.xaml Lines 13 to 14 in f704cdc
I put this lines to MainWindow.xaml and it works fine: <TextBlock FontSize="20" HorizontalAlignment="Center" Foreground="Aqua">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="{lex:Loc en}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static lex:LocalizeDictionary.Instance}, Path=Culture.TwoLetterISOLanguageName}"
Value="de">
<Setter Property="Text" Value="{Binding Source={lex:Loc de}}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock> If you have same lines, could you create a sample project? |
@Karnah Thanks! I tried it without any luck. I have setup an example repo here with my use case described: https://github.com/NiklasMoller/WPFLocalizationExtensionsWithSetters Could you please help me and others struggling with this? Thanks :) |
@NiklasMoller, sorry, I didn't understand your problem first time. <Style x:Key="SelectUserStyle" TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding XPath=configurations/PatientType}" Value="PLP">
<Setter x:Name="LoginPageTitlePLP" Property="Text" Value="{Binding Source={lex:Loc LoginPageTitlePLP, ForceCulture='sv-SE'}}"/>
</DataTrigger>
<DataTrigger Binding="{Binding XPath=configurations/PatientType}" Value="SCI">
<Setter x:Name="LoginPageTitleSCI" Property="Text" Value="{Binding Source={lex:Loc LoginPageTitleSCI, ForceCulture='sv-SE'}}"/>
</DataTrigger>
</Style.Triggers>
</Style> Also you said about |
@Karnah Brilliant! Specifying the key works fine 👍 With "to be able to set any language" I meant that the text should adapt depending on which CultureInfo is being specified. Works fine just specifying the key. Many thanks for your help with this 🥇 |
update Docu:
The text was updated successfully, but these errors were encountered: