Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
All as the subject i have contentpresenter how show date in scheduler view this default contentTemplate show date in short format but i want to show the daate in custom format:
example:

the default ContentPresenter:

<contentcontrol x:name="Content" margin="-2" content="{TemplateBinding Content}" xmlns:x="#unknown">
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center" />

this.xaml show the date in this format: 12/02/2013

but i want to change this in order to show this: 04 Tue.

what should i change in order to reach this object???
and thx for all you helps.

[Edit: Moved from OP's Answer]
CSS
Sorry guys i have an error in my question

12/02/2013 is should convert to 12 Tue.

xaml show the date in this format: 12/02/2013

but i want to change this in order to show this: 12 Tue.
Posted
Updated 12-Feb-13 3:39am
v2

i did do this and it is worked:
<contentcontrol x:name="Content" margin="-2" content="{TemplateBinding Content}" xmlns:x="#unknown">
ContentTemplate="{DynamicResource LabelTemplate}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center" />

i did and ContentTemplate referred to labelTemplate

<datatemplate x:key="LabelTemplate">

 
Share this answer
 
The simple way to do this is to use String.Format(), which you can read more about here:

http://msdn.microsoft.com/en-us/library/az4se3k1.aspx

However, if you are using XAML databinding (as I assume you are from the code snippet above), you can add a converter to your binding statement to make any format you'd like. You can read more about that here:

http://social.msdn.microsoft.com/Forums/en/wpf/thread/ca42be91-3d72-46e5-8624-9610a97cce71
 
Share this answer
 
You can use a StringFormat in your binding to change the way that this is displayed. As your example doesn't match - i.e. 04 Tue isn't the same as 12/02/2013 and I can't see how you derives this, I can't give you the exact string. However, you could start by reading up about WPF and StringFormat in XAML.
 
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