c# - WPF formatting labels with StringFormat -


i have wpf application. have labels , datagrids bound public properties. of these properties numerical values.

in datagrids have been using line below ensure values display 2 decimal places, works. when use same line below label appears have no effect on display number shows 9 decimal places. don't understand why works datagrid not label?

stringformat={}{0:0.##}    <label grid.row="3" grid.column="1"        content="{binding obs.tstat, stringformat={}{0:0.#}}"         horizontalalignment="center" foreground="{staticresource brushlinfont}"         fontsize="13" fontweight="bold"/> 

updated code

 <label grid.row="3" grid.column="1"         content="{binding obs.tstat}" contentstringformat="{}{0:0.#}}"          horizontalalignment="center" foreground="{staticresource brushlinfont}"          fontsize="13" fontweight="bold"/> 

for label need use contentstringformat:

<label content="{binding obs.tstat}" contentstringformat="{}{0:0.##}"/> 

reason:

label's content property of type object , stringformat used when binding property of type string.

if try code textblock's text property work fine stringformat because text property of type string.


Comments

Popular posts from this blog

Android Java.Lang.RuntimeException : Unable to start activity Component Info -

php - htaccess subdomain and directory redirect -

c# - Sort XmlNodeList with a specific Node value -