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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -