Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i display date formats in dd-MM-yyyy format in wpf application using VS2010
Posted
Updated 12-Jan-12 19:37pm
v2

You generally use the StringFormat attribute to set the way a control displays dates etc. Something like this :-

XML
<textbox text="{Binding Path=YourDate, StringFormat='dd MMM yyyy'}" />

This will show the date as 13 Jan 2012

Hope this helps
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Jan-12 3:17am    
This is the answer, my 5, OP is recommended to accept it.
--SA
Wayne Gaylard 13-Jan-12 3:25am    
Thanks SA!
about "MM/dd/yyyy HH:mm:ss" format, please look at MSDN documentation about symbol '/' for custom formats http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx#dateSeparator
 
Share this answer
 
v2
xml:lang="en-IN"

use the above tag in your window or page...

all controls on the window or page follow the above menctioned language..

the date automatically displayed dd-MM-yyyy..
 
Share this answer
 
<setter property="Control.Template">
<setter.value>
<controltemplate>
<textbox x:name="PART_TextBox" xmlns:x="#unknown">
Text="{Binding Path=SelectedDate, StringFormat='dd MMM yyyy',
RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" /&gt;
</textbox></controltemplate>
</setter.value>
</setter>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900