c# - How to show Persian date in WPF DataGrid? -


how can change code (or somewhere else):

<datagridtemplatecolumn x:name="timecolumn" header="time" isreadonly="true">     <datagridtemplatecolumn.celltemplate>        <datatemplate>           <datepicker selecteddate="{binding time, mode=twoway, notifyonvalidationerror=true, validatesonexceptions=true}"/>        </datatemplate>      </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> 

to show date in persian format? time in database in timestamp format. want "show it" in persian format, , have persian calendar if possible.

if want show persiandatetime can use system.globalization.persiancalendar in view-model this:

    public string persiandate     {                 {             persiancalendar pc = new persiancalendar();             datetime thisdate = convert timestamp datetime here ...;             return string.format("{0}, {1}/{2}/{3} {4}:{5}:{6}",                           pc.getdayofweek(thisdate),                           pc.getmonth(thisdate),                           pc.getdayofmonth(thisdate),                           pc.getyear(thisdate),                           pc.gethour(thisdate),                           pc.getminute(thisdate),                           pc.getsecond(thisdate));         }     } 

and in xaml:

    <datagrid itemssource="{binding yourlist}" autogeneratecolumns="false">         <datagrid.columns>             <datagridtextcolumn header="persiantime" binding="{binding persiandate}"/>             < other columns ... />         </datagrid.columns>     </datagrid> 

if need persian calendar in farsi format , language, may want check out this library, source this link code project.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -