How to use StringFormat in XAML elements?

前端 未结 4 2101
难免孤独
难免孤独 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:06

    In general, you can look for an associated *StringFormat dependency property. For example, all ContentControl implementations (such as Label and Tooltip) have the ContentStringFormat dependency property:

    In your case, while the GridViewColumn has the HeaderStringFormat dependency property to go along with Header, there is no analog for the DisplayMemberBinding and so you will need .NET 3.5 SP1 (get it with Visual Studio 2008 SP1) or better to use the new BindingBase.StringFormat Property:

    
    

    There are lots more examples at the blog post Trying out Binding.StringFormat.

提交回复
热议问题