This is a migrated thread and some comments may be shown as answers.

DateTimePicker focus

4 Answers 220 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason D
Top achievements
Rank 1
Veteran
Jason D asked on 04 Jan 2017, 12:24 AM

This is my first attempt with this grid. One of my columns contains datetime values. Because I want the button for the editor to always be visible, I created a CellTemplate as I saw mentioned in the forum. This works fine. However, once I'm in the editor, nothing will close or hide the editor, even if I click on another cell or control or hit Escape.

<telerik:GridViewDataColumn DataMemberBinding="{Binding Timestamp}" Width="200">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <telerik:RadDatePicker SelectedDate="{Binding Timestamp}" IsTooltipEnabled="False"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

4 Answers, 1 is accepted

Sort by
0
Jason D
Top achievements
Rank 1
Veteran
answered on 05 Jan 2017, 11:25 PM

Ok, after spending more time with the DatePicker I figured out this is the correct behavior. However, I need to change the style so that *only* the button is shown when the cell is not in edit mode. I think I can figure this out but will post back if not.

I'm also having issues with the date range. I see you added IsInputRestrictedToSelectableDates to the Q1 2016 release. How can I replicate that with the 2014.3 release?

Do I bind SelectedDate or SelectedValue? Finally, regardless of which one I bind to, the content is always left-aligned, even if I specify right-aligned. Thanks!

0
Stefan Nenchev
Telerik team
answered on 06 Jan 2017, 01:21 PM
Hi Jason,

You can use a RadDateTimePicker as shown in the following article - How to use RadDateTimePicker in a Grid. Would this work for you? Eventually, you can modify the RadDateTimePicker so that it meets your visual requirements.

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Jason D
Top achievements
Rank 1
Veteran
answered on 06 Jan 2017, 04:09 PM
Right, I saw that. It's my other two problems that are now causing issues (see my follow-up reply).
0
Stefan Nenchev
Telerik team
answered on 10 Jan 2017, 10:41 AM
Hi Jason,

In order to set the alignment of the you can edit its control template and modify the RadWatermarkTextBox element that is contained so that its TextAlignment property is set to Right.  A possible solution would also be to change it when the RadDateTimePicker is loaded:

private void RadDateTimePicker_Loaded(object sender, RoutedEventArgs e)
       {
          (sender as RadDateTimePicker).ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault().TextAlignment = TextAlignment.Right;
       }

Unfortunately, replicating the IsInputRestrictedToSelectableDates not be that straightforward so you will need to come up with some custom solution at your end or consider upgrading the control's version.  

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Jason D
Top achievements
Rank 1
Veteran
Answers by
Jason D
Top achievements
Rank 1
Veteran
Stefan Nenchev
Telerik team
Share this question
or