How to use StringFormat in XAML elements?

前端 未结 4 2028
难免孤独
难免孤独 2021-01-31 07:20

I\'m deep in a XAML stack of elements binding to orders.

The order date displays as e.g. \"12/31/2008 12:00:00 AM\".

I want it to display as e.g. \"31.12

4条回答
  •  花落未央
    2021-01-31 08:00

    If you wanted to localize the date format, you can include it in your .resx file. You will have to set up your app for localization by following this guide: https://developer.xamarin.com/guides/xamarin-forms/advanced/localization/.

    The resx entry:

    
        {0:ffffdd d MMMM H:mm}
    
    

    In your content page, you then include the location of the resx file

    xmlns:il8n="clr-namespace:MyProject.Localization;assembly=MyProject"
    

    And then you can use it in your binding like so:

提交回复
热议问题