我使用设计框架mahapps.metro作为datagridnumericupdowncolumn:https://mahapps.com/controls/datagrid.html
有一个stringformat = C的例子。但我只需要D代替没有逗号的数字:string formats defined by microsoft
<Controls:DataGridNumericUpDownColumn Binding="{Binding DECIMAL_BINDING_VALUE}" StringFormat="D" Minimum="1" HideUpDownButtons="True"/>
绑定变量DECIMAL_BINDING_VALUE的默认值是12345.如果我打开窗口,Visual Studio将抛出异常:System.FormatException:“Format is invalid”。如果我使用String.Format = C我没有错误....
如何在XAML中使用DatagridNumericUpDownColumn为无逗号定义正确的StringFormat?
尝试:
<Controls:DataGridNumericUpDownColumn Binding="{Binding DECIMAL_BINDING_VALUE, StringFormat='\{0:D\}'}" Minimum="1" HideUpDownButtons="True"/>
随着StringFormat
内部的Binding
。
这就是它在BindingBase.StringFormat Property docs中的表现。