Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF
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:


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]
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 12-Feb-13 1:32am
Edited 12-Feb-13 4:39am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

i did do this and it is worked:

ContentTemplate="{DynamicResource LabelTemplate}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center" />

i did and ContentTemplate referred to labelTemplate


<label content="{Binding Content.DateTime,StringFormat={}{0:dd ddd},Converter={StaticResource DateConverter}}" />
  Permalink  

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

  Print Answers RSS
0 Sascha Lefévre 500
1 Sergey Alexandrovich Kryukov 300
2 Abhinav S 230
3 Maciej Los 210
4 Richard Deeming 105
0 Sergey Alexandrovich Kryukov 6,928
1 OriginalGriff 6,381
2 Maciej Los 2,782
3 Abhinav S 2,732
4 Peter Leow 2,694


Advertise | Privacy | Mobile
Web02 | 2.8.150414.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100