This question is locked. New answers and comments are not allowed.
Hello,
I am working with the RadDateTimePicker. I have implemented some logic in my setter such that when a user chooses a date, it will revert back to the previous Saturday. (see GetCorrectedDate in my code) .
This seems to almost work properly - the textbox is updated appropriately and the SelectedValue is set properly but the calendar is not updated.
Try this:
1) Click the "Tuesday August 2nd 2011" button which will set the DataContext and SelectedValue to 8/2/2011 which will be changed to 7/30/2011).
2) Now open the datepicker and notice everything looks fine. select July 26 from the picker and notice that it closes, the textbox is updated to 7/23/2011, the SelectedValue property is changed.
3) reopen the calendar and notice that July 26 is still "selected"...
I am working with the RadDateTimePicker. I have implemented some logic in my setter such that when a user chooses a date, it will revert back to the previous Saturday. (see GetCorrectedDate in my code) .
This seems to almost work properly - the textbox is updated appropriately and the SelectedValue is set properly but the calendar is not updated.
Try this:
1) Click the "Tuesday August 2nd 2011" button which will set the DataContext and SelectedValue to 8/2/2011 which will be changed to 7/30/2011).
2) Now open the datepicker and notice everything looks fine. select July 26 from the picker and notice that it closes, the textbox is updated to 7/23/2011, the SelectedValue property is changed.
3) reopen the calendar and notice that July 26 is still "selected"...
<UserControl x:Class="SilverlightApplication56.MainPage" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"> <StackPanel> <Button Content="Tuesday August 2nd 2011" Click="Button_Click1" Margin="10" /> <telerik:RadDatePicker x:Name="dp" SelectedValue="{Binding TheDate, Mode=TwoWay}" Margin="10" /> </StackPanel></UserControl>using System;using System.Windows;using System.Windows.Controls;namespace SilverlightApplication56{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void Button_Click1(object sender, RoutedEventArgs e) { this.DataContext = new SomeVM(new DateTime(2011, 08, 02, 15, 35, 57)); } }}using System;using System.ComponentModel;namespace SilverlightApplication56{ public class SomeVM : INotifyPropertyChanged { public SomeVM(DateTime i) { this.TheDate = i; } private DateTime _TheDate = DateTime.MinValue; public DateTime TheDate { get { return _TheDate; } set { _TheDate = GetCorrectedDate(value); RaisePropertyChanged("TheDate"); } } private DateTime GetCorrectedDate(DateTime dt) { DateTime resultDate = dt; while (resultDate.DayOfWeek != DayOfWeek.Saturday) { resultDate = resultDate.AddDays(-1); } return resultDate; } public event PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } }}