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

DataBinding to RadDatePicker

10 Answers 1115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 25 Jun 2008, 10:24 PM
I have the following code:

<

Telerik:RadDatePicker Width="150" Height="Auto" SelectedDate="{Binding Path=TrainingDate}" IsTodayHighlighted="True" />

When, I run, the DatePicker reflects the bound value, however if I pick a new date, the bound field does not get updated.  Before I used the datepicker control, I just had a textbox which bound to the field just fine.

Thanks,

Eric

10 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 26 Jun 2008, 08:21 AM
Hi Eric,

By default most of the bindings are one-way. What you need is a two-way binding which you get when you define the binding as:

<telerik:RadDatePicker Width="150" Height="Auto"   
SelectedDate="{Binding Path=TrainingDate,Mode=TwoWay}" /> 

i.e. Mode=TwoWay

For two-way binding to work the source must be either a DependencyProperty or implement INotifyProeprtyChanged.

I created a simple project that demonstrates this, hopefully that would solve your problem.

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Eric
Top achievements
Rank 1
answered on 26 Jun 2008, 04:10 PM
Thanks guys,

Setting the Mode=TwoWay made it work properly.  One observation is that the other controls had the Mode set to TwoWay by default without me having to explicitly set it.  Seems like an inconsistent behaviour...

Eric
0
Miroslav
Telerik team
answered on 27 Jun 2008, 07:09 AM
Hello Eric,

Sometimes it is debatable what should the default binding be but in the case of the SelectedDate of the DatePicker, TwoWay is more logical. We will change it for the next release.

Thank you for the feedback.

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rieni De Rijke
Top achievements
Rank 1
answered on 16 Jun 2010, 02:39 PM
You wrote on Jun 27, 2008:
<<Sometimes it is debatable what should the default binding be but in the case of the SelectedDate of the DatePicker, TwoWay is more logical. We will change it for the next release.>>

It seems to us that this is still not "TwoWays" as default...   8-)
0
Kaloyan
Telerik team
answered on 21 Jun 2010, 01:26 PM
Hi Rieni De Rijke,

We are not doing any further developing regarding the RadTimePicker as we are currently working on a new control(RadDateTimePicker) that is about to replace the RadDatePicker and RadTimePicker. If you are still using the RadTimePicker you have to set the Mode=TwoWay in your binding.

Kind regards,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
techvslife
Top achievements
Rank 1
answered on 26 Aug 2010, 11:15 PM
Can you give me an example of how to set it to two-way from c# (can't use xaml here)?  Thank you.

using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Telerik.Windows.Controls;
namespace MyLsTest
{
public partial class MyScreen
{
  partial void MyScreen_Loaded()
  {
   IContentItemProxy proxyTme = this.FindControl("EntryTme1");
   proxyTme.Invoke(() =>
    {
     var ctlTme = (Telerik.Windows.Controls.RadTimePicker)proxyTme.Control;
    
     /*What property to set here to chage to two way binding ? */

    });
  }
}
}
0
Kaloyan
Telerik team
answered on 27 Aug 2010, 12:59 PM
Hello techvslife,

See the code posted bellow:

radTimePicker.SetBinding(RadTimePicker.SelectedTimeProperty, new Binding("YourProperty") { Source = yourSource, Mode = BindingMode.TwoWay });

Regards,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
techvslife
Top achievements
Rank 1
answered on 27 Aug 2010, 10:12 PM
Kaloyan,
Thank you.   Now all I have to do is figure out what Lightswitch wants for yourSource and yourProperty.

0
Yaakov Smith
Top achievements
Rank 1
answered on 22 Feb 2011, 04:10 PM
I am using the RadDateTimePicker and have found that the default is One Way - It took me quite a while to figure out this was the problem. Please amend the default to Two Way to save others from experiencing the same aggravation.

0
Kaloyan
Telerik team
answered on 24 Feb 2011, 10:29 AM
Hello Yaakov Smith,

We will consider the fix for the next iteration of the control.

All the best,
Kaloyan
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Eric
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Eric
Top achievements
Rank 1
Rieni De Rijke
Top achievements
Rank 1
Kaloyan
Telerik team
techvslife
Top achievements
Rank 1
Yaakov Smith
Top achievements
Rank 1
Share this question
or