WPF formatting labels with StringFormat

后端 未结 2 2205
难免孤独
难免孤独 2021-02-14 10:04

I have a WPF application. I have some labels and some datagrids which are bound to some public properties. Some of these properties are numerical values.

In the datagrid

2条回答
  •  难免孤独
    2021-02-14 10:35

    For label you need to use ContentStringFormat:


    Reason:

    Label's Content property is of type object and StringFormat is used only when binding property is of type String.

    If you try your code with TextBlock's Text property it will work fine with StringFormat because Text property is of type string.

提交回复
热议问题