[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

WPF DatePicker control

Posted on 2011-05-12
10
Medium Priority
?
2,776 Views
Last Modified: 2013-12-16
In WinForms, it's possible to customize the display format of the control itself. I'd just set the format to custom, and specify a custom format (i.e., "yyyy-MM-dd HH:mm:ss"). In this case, the display value on the control would show something like "2011-05-12 16:30:00".

I'd like to use this same functionality in a WPF solution but I can't seem to determine how to do it. As best as I can tell, the only format-related property that I can manipulate on the DatePicker is the SelectedDateFormat, which can only be set to Long or Short. By default the control assumes a time of midnight, however if the user manually types the date (including a time), the DatePicker seems to use this as the selected datetime.

How can I get it to actually show the time in addition to the date on the control itself?
0
Comment
Question by:elorc
  • 6
  • 4
10 Comments
 
LVL 11

Expert Comment

by:saragani
ID: 35750164
WPF 4.0 doesn't come with a Date Picker as much as I know... No <Calendar /> or <DatePicker /> available.
Are you sure you are not using a 3rd party control?
(For example, from a toolkit, like the WPF Toolkit?)
0
 
LVL 11

Accepted Solution

by:
saragani earned 2000 total points
ID: 35750277
Hi, in case you are using The WPF ToolKit, then there is an extended version with new features.
Version 1.4 supports formatting.

You can do:
 Format="Custom" FormatString="yyyy-MM-dd HH:mm:ss"
0
 
LVL 11

Expert Comment

by:saragani
ID: 35750288
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 1

Author Comment

by:elorc
ID: 35755060
This doesn't seem to be working. I downloaded the extended library, moved it into my system32 folder. Then I included it in my project (Visual C# 2010 Express) and created a window:

<Window x:Class="TestProject.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
        Title="Window1" Height="300" Width="300">
    <Grid>
        <extToolkit:MaskedTextBox Mask="(000) 000-0000" Value="5555551212" />
    </Grid>
</Window>

Open in new window


The XAML editor highlights the extToolkit:MaskedTextBox tag and says:

The type 'extToolkit:MaskedTextBox' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

I don't understand what's wrong here. This is an example directly from the extended toolkit's documentation, and WPFToolkit.Extended is definitely listed under my project's references.
0
 
LVL 11

Expert Comment

by:saragani
ID: 35756545
0
 
LVL 11

Expert Comment

by:saragani
ID: 35756576
Btw, the DLL is compiled in .Net 4.0 so maybe that is the reason why your visual studio doesn't find it
(Maybe your project is .Net 3.5).
0
 
LVL 1

Author Comment

by:elorc
ID: 35756789
My project appears to be 4.0. When I check the properties of the references PresentationCore, PresentationFramework, and WindowsBase, they all show as Version 4.0.0.0 (runtime 4.0.30319).
0
 
LVL 11

Expert Comment

by:saragani
ID: 35756810
Does my example I shared by rapidshare / megaupload work for you?
0
 
LVL 1

Author Comment

by:elorc
ID: 35756990
Well I somehow got it to work, but I don't know how. Your project worked, but mine still didn't. After tweaking around I got it to work and I think it may have been a permissions thing.

I moved the WPFToolkit.Extended.dll from system32 to my project file. Saved the project, still gave me the error. So I closed the project, created a new one and it worked in the new project. I closed that project, reopened my original one, and without making any further changes, it worked.

huh. :)
0
 
LVL 1

Author Comment

by:elorc
ID: 35756996
Correction: I moved it from system32 to my project folder, not file.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month19 days, 9 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question