View previous topic :: View next topic |
Author |
Message |
bdwyer
Joined: 27 Aug 2012 Posts: 10
|
Posted: Tue Sep 25, 2012 2:27 pm Post subject: Replacement inside of a binding |
|
|
While I can manually use a ResX inside the textblock below, the auto scanner doesn't pick it up, even if I turn on StringFormat attributes as something to go after.
Is there any creative way to get the scanner to ResXify strings inside a binding as below?
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=local:MainWindow}, Path=ConnectionRetryCount, StringFormat='Please wait while a connection to the server is re-established (attempt {0} of 10)...'}" |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Sep 25, 2012 10:50 pm Post subject: |
|
|
The Globalizer scanner only converts simple properties to use the ResX extension. Even if it could convert the StringFormat property this only works if you don't try to change the culture dynamically - because Bindings don't allow the StringFormat property to change once it has been set. Instead you should change the XAML to use the Binding properties of the ResX extension eg
Code: | <TextBlock>
<Resx Key="MyFormatString" BindingRelativeSource={RelativeSource AncestorType=local:MainWindow}, BindingPath=ConnectionRetryCount/>
</TextBlock> |
Where MyFormatString is the key for a resource you added to the window resources file manually. Globalizer will automatically scan items that have been added to the resources file manually. See the section Formatting Bound Data in the code project
WPF Localization Using RESX Files article for more details. _________________ Infralution Support |
|
Back to top |
|
|
|