locked
Binding is missing StringFormat property and others RRS feed

  • Question

  • Is Binding getting a (very useful) StringFormat property in future? Or should we once more create yet another StringFormatConverter?
    Miha Markic [MVP C#] http://blog.rthand.com
    Tuesday, October 4, 2011 9:21 AM

Answers

All replies

  • Hi Miha, yes right now in the developer preview you would use a converter that you supply.  We are aware of this feedback on StringFormat and evaluating.
    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
    Tuesday, October 4, 2011 3:39 PM
  • Hi Tim,

    I think that StringFormat is particulary useful. Often you want to show some text which has to be formatted first and possibly converted. In the later case you'd have to create a specific converter - you'd have to convert the source to text and then format it - something that can't be done by simply using StringFormatConverter.

    By the way, did you ever consider Converter chaining? It would be useful as well.


    Miha Markic [MVP C#] http://blog.rthand.com
    Wednesday, October 5, 2011 7:24 AM
  • Can you give me your top uses for StringFormat?
    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    Wednesday, October 5, 2011 5:14 PM
  • You know Josh Smith implemented a Chaining Converter a while back for WPF, I wonder if it could be ported to WinRT
    Keep your head in the Clouds as you're coding .NET http://azurecoding.net
    Friday, October 7, 2011 10:22 AM
  • Well, I can try :) 

    I use it all over the place in my POS app. I'm from Europe (as our customers) and Europe have 50+ Countries and even more languages. To support that, we use StringFormat in Binding for date formatting , Display of Currency, correct decimal places (. or ,)   and what not. For sure, it would make my life easier if you include StringFormat :)  

    Wednesday, March 7, 2012 5:48 PM
  • Yes, it is puzzling that such a crucial feature, that presumably is relatively simple to implement is not actually available.  Makes maintaining code between the phone and WinRT another bit harder...

    PLEASE  put it in for the final release.

    Thursday, April 26, 2012 12:13 AM
  • I agree this is a crucial feature, we use it all the time to manage even simple things like decimal places when showing doubles.
    Friday, May 4, 2012 2:16 PM
  • @StefanOlson - StringFormat for Binding statements will not make the release.  I understand that while it is easy to think 'wow this is so easy, just do it' - we have a lot of API surface area and have to prioritize our resources.  This is something that is on our radar for update releases though.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Friday, May 4, 2012 3:16 PM
  • @Tim,

    Sure, I understand that.  The way I would prioritise your resources and the way that actually happens, may not be the same :-) Having said that I'm not sure this is something that I would prioritise, because a simple string format converter does work and is compatible between WPF Silverlight and WinRT.  My priority would be things that can't be worked around easily, like relative source ancestor binding, multi-binding, implicit styles for rich text block, hyperlinks for rich text block, tooltip delay settings etc...

    ...Stefan

    Friday, May 4, 2012 8:09 PM
  • @StefanOlson - you got it, this has a simple workaround so it isn't *critical* here.  The other items you mention are things we're thinking about, but not going to make it.  The Hyperlink in RTB...I assume you mean the Hyperlink class (as you can do the HyperlinkButton with InlineUIContainer).  I think I may have mentioned this before (not that it is any consolation but helps you understand the starting point) is we are more like Silverlight for Phone than WPF.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Saturday, May 5, 2012 12:30 AM
  • @Tim,

    Yes I understand that you are more like Silverlight for the Phone, and yes that is a major disappointment, because WPF was just such a beautifully designed system, as seen by the fact that no huge updates have not really been required since version 3.5.  Yes, there are still things that could be improved in WPF, and there are some improvements  in WinRT that would be good to have in WPF, but overall it was much more complete than Silverlight/WinRT has been.

    Anyway, dealing with the Hyperlink (not the button because that doesn't wrap), it is there in Silverlight for the Phone:

    public sealed class Hyperlink : System.Windows.Documents.Span
        Member of System.Windows.Documents
    

    And that means that you can't have a newsreader type application in WinRT C# ( if you want links anyway ).  I have two of them that I have built for the phone,  lack of hyperlinks is one reason is going to be very difficult or impossible to port.

    ...Stefan

    Saturday, May 5, 2012 12:38 AM