c# - Binding StringFormat in Windows Phone -
c# - Binding StringFormat in Windows Phone -
i develop silverlight app windows phone 8. bind integer value in longlistselector illustration 123. , want create looks 000123
<phone:longlistselector itemssource="{binding allvalues}"> <phone:longlistselector.itemtemplate> <datatemplate> <stackpanel> <textblock x:name="valueblock" text="{binding valuevalue}" horizontalalignment="left" verticalalignment="center" style="{staticresource phonetextlargestyle}"/> ...
i know stringformat can this, problem number of leading zeros different , want bind viewmodel.
... text="{binding valuevalue}, stringformat=\{0:d6\}" ...
how can bind number after d in stringformat?
you can't bind stringformat
part of binding expression. can instead add together property view model "valuedisplay".
public string valuedisplay { { homecoming string.format("{0:" + valueformat + "}", valuevalue); } } public string valueformat { { homecoming _valueformat; } set { _valueformat = value; raisepropertychanged("valuedisplay"); } } private string _valueformat;
c# windows-phone-8 windows-phone
Comments
Post a Comment