Override WPFToolkit DatePickerTextBox control to Customized Combobox control - wpf

I want to use WPFToolkit DatePicker to insert date into my Combo box. By default, DatePicker comes with Text box for date. I know WPFToolkit has DatePickerTextBox Control for Textbox. I want to override it into ComboBox control. I don't know how to override this control.
I have a control which has some default parameters for date that is in combobox options such as One Year Ago, 2011, 2010, 2009, etc. When I select particular date from datepicker I want to display that date into combobox control.
I hope this question is clear.

You are not going to be able to override this control directly. The only suggestion I can make is to play around with ElementName binding between that control and the ComboBox SelectedValue property to get the desired behavior.
After that if you are really determined you can replace the default style template for the DatePickerTextBox control to hide the TextBox element and put your ComboBox wherever you want in the UI making it appear to do what you want.

I found Calendar Control in WPFToolkit. I am using Calendar Control in MenuItem control with Combo box by side. It will be same as DatePicker control but instead of Textbox I will have Combo Box with other options in it.
It served my purpose of having ComboBox and DatePicker.

Related

Writable ComboBox in Silverlight

How can we change a Silverlight ComboBox writable like in Windows Form when we change the DropDown property.
I believe the closest you can get is autocompletebox
ComboBox in Silverlight does not have IsReadonly and IsEditable properties like WPF that allow it to be editable.
You will have to create a custom control or a user control to mimic that behavior.

How to 'get at' the WPF combobox PART_EditableTextbox because combobox not getting highlighted?

My WPF combobox is populated with a different set of strings each click of a button. There are other controls on the window as well. The combobox is the 'first' (top) in the window, but the text doesn't get highlighted. When the user tabs through the controls, the text DOES get highlighted, but when it's the first on the window, it doesn't.
Maybe i need to force a highlight on the individual textbox control 'within' the combobox itself, but how would i do this? I couldnt seem to find the internal 'structure' of this control anywhere. Could anyone help here?
Jack
to get the TextBox of Combobox you can use
TextBox TxtBox = (TextBox)myCombo.Template.FindName("PART_EditableTextBox", myCombo);
I'm not sure it's the best solution, but you can use FrameworkElement.FindName to access the child control -- it's guaranteed to be present in a combobox, because it's a key constituent part of the control.
That stated, is it not better to try and call .Focus() on the control? That is likely why when you tab, the highlight is provided.
Another option is to derive from ComboBox, and expose the child text box as a property allowing you to set it's selection, or add a method directly to the combobox to set it for you.

Showing a tooltip on a combobox from the itemtemplate (WPF)

I have a ComboBox with a DataTemplate. The DataTemplate has two controls, each of which has a ToolTip attached to it. The list of items of the ComboBox has the tooltips as expected when you hover over each control. But the selected item area on top of the ComboBox does not display the tooltips, though the controls are rendered as expected. Is there a way to force the tooltips to be displayed?
If you're using Mole or something similar, make sure that your control with the attached ToolTIp has IsHitTestVisible="True". Otherwise, the control is not listening for mouse events and will not recognize that the ToolTip should be shown in the first place.
You may also want to look at binding the ToolTip of the selected item to the ContentPresenter in the ComboBox since, after selection, your SelectedItem becomes the content of the ComboBox. You may need to override the ComboBox template and make sure the ContentPresenter can accept mouse input in order to force your ToolTip's visibility.

WPF Custom Control Design question

I have a design question:
If you had to make a WPF Combobox with search support,
(= combobox that shows a popup with some Buttons, Search TextBox, List.. etc
the selected item feed to the default's ComboBox TextBox.)
What would you do?
Write a custom control (diretly inheriting from System.Windows.Control)
Write a custom control inheritnig from Selector / ComboBox
Make a UserControl
Use a default ComboBox with a 'special Template' (CotnrolTemplate/Style ?) extended to search functionality
Use a default ComboBox with style and attached EventHandlers..
Thank you guys !
I have done that, and the method i used was option 2 - i did a template control inheriting from a third party combo, and replaced the popup contents with my own template.

DatePicker with the ability to choose a span

Here is a quick visual of the idea that I got from Google Analytics.
ComboBox Collapsed:
ComboBox Collapsed http://www.googlemapscontrol.net/images/CalendarDropDownClosed.jpg
ComboBox Expanded:
ComboBox Expanded http://www.googlemapscontrol.net/images/CalendarDropDownOpen.jpg
I am not concerned with the functionality of the timeline or the date range text boxes. Basically I am looking to have something that looks kind of like a ComboBox with a single calendar control. When the date range is selected and the control is closed then the range is shown in the text box.
I don't think that I can get a ComboBox to behave this way and I think that I need to use something along the lines of a textblock, button and a popup.
Does anyone have a sample I can start with?
If you don't have a sample how would you approach this issue?
Thanks
The WPF Toolkit has a Calendar/DatePicker control that could be a suitable base for you to modify into an elaborate date range picker.
I would start with the DatePicker Generic.xaml file from the WPF Toolkit distribution, and examine what they have done with the DatePicker control template. The interesting section for you will be around the area that PART_TextBox and PART_Button is used. They indeed use a combination of grids, textbox, button, and popup controls.
Hope that helps!

Resources