I am currently working on WP8 and my requirement is to create a item which allows user to select both Date and Time and the details are combined and added in TextBox.
Can anyone suggest is there any third party control using which I can add this control or I should just create Custom Control ?
I am aware of creating custom control but it becomes difficult when managing data.
Related
I have to create simple application. User selects time period and I get data from database for selected period and put it on the graph. How are graphs generated in c#. What library should I use for this?
Well, you can from the tool box drag in a chart control.
eg:
And you can even use the wizard to setup the data source.
So, the built in chart control is a good start. Perahps there is some reason you don't want to use this asp.net control?
I'm pretty new to XAML/C# and have a view that contains two textboxes. When the user clicks on the textbox, I want it to open up a basic calendar with either today's date or the date of the textbox. Once the date has been clicked, I want it to return that value.
I was going to create a new XAML view with a calendar control and then work it with variables, but before I did that I wanted to know if there is a better / more technically correct way.
Thank you.
If you are developing WPF application then just use DatePicker control and if you want to get time also then install Extended WPF Toolkit in that use the DateTimePicker Control...
Developing for Windows Phone or WinRT (Windows Store) apps use DatePicker Control.
According to this post, there's a separate DatePicker control in .net 4. I've tried it, and I don't see a good way to also let it select the time of the day.
Is there an easy way to transform DatePicker into DateTimePicker by editing XAML template? If not, what is the best way to get a DateTimePicker for WPF 4.0?
Extended WPF Toolkit sports a nice DateTimePicker with time of day.
There is also an article over on CP where someone created a control that works like the Winforms one... A WPF DateTimePicker That Works Like the One in Winforms
There isn't one without making it yourself or using a 3rd party control. However there is one within winforms if you want a quick fix that doesn't support data binding...
xmlns:window="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
<window:WindowsFormsHost >
<wf:DateTimePicker Format="Time" ></wf:DateTimePicker>
</window:WindowsFormsHost>
Just a time picker, but could easily be paired with a datepicker. You also need a reference to WindowsFormsIntegration and System.Windows.Forms.
Try the DateTimePicker in the extended WPF toolkit.
If you do want an DateTimePicker without external controls and also for commercial use, I've improved an existing one and share it here:
https://gist.github.com/Apflkuacha/406e755c8b42a70b7ab138e6b985bcdf
It will look like this, a field which shows the selected date&time and a popup window to select the date and time:
I was wondering is it possible to disable selected dates in a DateTimePicker, so that user cannot select them. i know its possible in web forms but in windows forms im unable to do this.how can i achieve this.
The ease with which you can do this will depend on the dates you want to restrict. For instance, if you all you want to do is specify a range of valid dates to pick, then you can use the MinDate and MaxDate properties to set the bounds. If however, you want to cherry pick certain days within a range (for instance, no weekends), there is no built in method for doing this.
You could either find a third party control with this functionality, or you could try to hack it a bit by adding an event handler to the ValueChanged event, and forcing the current date time to the last value (which you'd have to cache) if they user picked something that was illegal according to your business logic... but this is a less than ideal way to do it.
Developer Express controls are usually very flexible and judging from this support article you can achieve what you want to do with their DateEdit control.
The control collection can be obtained from the following location: Over 60 Free Controls from DevExpress. (the free offer is no longer available)
Don't forget to read the EULA.
This question already has answers here:
What is the difference between a User Control Library and a Custom Control Library?
(3 answers)
Closed 1 year ago.
I'm working on creating a date/time user control in WPF using C# 2008. My first user control. I'm also using Matthew MacDonald's book, "Pro WPF in C# 2008". In that book he strongly recommended creating a user control using the WPF Custom Control Library project template; so I followed his suggestion. I've finished writing the code which would go into what I think of as the code-behind file. Now I'm ready to write the XAML.
The only problem is, I just discovered there is no corresponding .xaml file? So, I don't get why using a WPF Custom Control Library project is better, or prefered, when writing a user control?
A user control and a custom control solve two distinctly different problems.
UserControls are meant to compose multiple WPF controls together, in order to make a set of functionality built out of other controls. This is often used to compose a portion of a window or screen in order to organize your development by allowing you to group multiple pieces of functionality into one "control". For example, if you wanted to make a control for editing a User which provided text boxes for first and last name, age, etc., a single UserControl could be dropped onto a Window and bound to a User instance to edit this. (In this case, you're using standard controls, such as TextBox, to "compose" a control for a more complex purpose.)
A CustomControl, however, is meant to be a new single control. This would typically be a replacement for a built-in control (which could not be redone via templating). I've found that the need for CustomControls is actually fairly rare in WPF, since the WPF templating options and attached properties allow you to do nearly anything with standard controls, once you learn them fully.
I would also add, if you're intending to inherit from your control, then using a usercontrol is will complicate matters. For example, if create a base usercontrol that has a layout defined in Xaml, WPF framework won't allow you to inherit this control and use Xaml to define the layout for the subclass. In dotnet 3.5 Xaml control can't inherit from another Xaml control