Click here to Skip to main content
12,956,234 members (61,063 online)
Rate this:
 
Please Sign up or sign in to vote.
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]
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 0:32am
Updated 12-Feb-13 3: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:
<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">

  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,869
CHill60 3,550
Maciej Los 3,243
ppolymorphe 2,070
Jochen Arndt 1,973


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2017
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