Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wpf Multibinding StringFormat (.net 3.5 sp1)

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Globalizer Feature Requests
View previous topic :: View next topic  
Author Message
TravisWhidden



Joined: 26 Jan 2012
Posts: 8

PostPosted: Thu Jan 26, 2012 5:33 am    Post subject: Wpf Multibinding StringFormat (.net 3.5 sp1) Reply with quote



(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
View user's profile Send private message
TravisWhidden



Joined: 26 Jan 2012
Posts: 8

PostPosted: Fri Jan 27, 2012 1:23 am    Post subject: Reply with quote

Another example would be:


_________________
Travis
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4876

PostPosted: Fri Jan 27, 2012 11:22 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 4876

PostPosted: Thu Feb 23, 2012 5:46 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TravisWhidden



Joined: 26 Jan 2012
Posts: 8

PostPosted: Tue Mar 27, 2012 3:09 am    Post subject: Reply with quote

Great. Ill have to update my install. That will help!
_________________
Travis
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Globalizer Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group