View previous topic :: View next topic |
Author |
Message |
TravisWhidden
Joined: 26 Jan 2012 Posts: 8
|
Posted: Thu Jan 26, 2012 5:33 am Post subject: Wpf Multibinding StringFormat (.net 3.5 sp1) |
|
|
(code tags were stripping my xaml)
Would it be possible that you could include the feature that is new for .net 3.5 sp1 - StringFormat="" -- That would be very handy and nice!
The scan tool didn't pick any of that up.
Thanks! _________________ Travis |
|
Back to top |
|
|
TravisWhidden
Joined: 26 Jan 2012 Posts: 8
|
Posted: Fri Jan 27, 2012 1:23 am Post subject: |
|
|
Another example would be:
_________________ Travis |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Jan 27, 2012 11:22 pm Post subject: |
|
|
Unfortunately the properties of Binding and MultiBinding (including the StringFormat property) are sealed after the binding is used for the first time. This means that if you try to change them you will get an InvalidOperation exception with the message "binding cannot be changed after it has been used".
So while you can set the StringFormat property using the ResxExtension, if you change the CultureManager.UICulture then you will get the InvalidOperation exception when the CultureManager attempts to set the StringFormat property to its new value.
See the following thread on this topic:
http://www.infralution.com/phpBB2/viewtopic.php?p=7019 _________________ Infralution Support |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Feb 23, 2012 5:46 am Post subject: |
|
|
We have just released Version 3.2.0 of Globalizer which includes some new features in the Infralution.Localization.Wpf assembly to provide support for these scenarios.
To overcome the limitations of sealed Bindings the ResxExtension can now itself act like a binding. You simply set the binding properties (prefixed with "Binding") and the resource value is used as a format string. For instance the binding above would become:
Code: | <Resx Key="MyFormatString" BindingElementName="_fileListBox" BindingPath="SelectedItem"/> |
The ResxExtension also now supports formatting data from multiple data sources (similar to a MultiBinding) by nesting Resx elements. For instance:
Code: | <Resx Key="MyMultiFormatString">
<Resx BindingElementName="_fileListBox" BindingPath="Name"/>
<Resx BindingElementName="_fileListBox" BindingPath="SelectedItem"/>
</Resx> |
In this case you would define the MyMultiFormatString resource with placeholders for both data source arguments eg "Selected {0}: {1}". _________________ Infralution Support |
|
Back to top |
|
|
TravisWhidden
Joined: 26 Jan 2012 Posts: 8
|
Posted: Tue Mar 27, 2012 3:09 am Post subject: |
|
|
Great. Ill have to update my install. That will help! _________________ Travis |
|
Back to top |
|
|
|