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

Binding Issue (v2010.3.1314.40)

3 Answers 37 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Wyatt
Top achievements
Rank 1
Wyatt asked on 19 Dec 2011, 05:38 PM
Hi,

I'm having an issue binding with the RadDatePicker.  I'm using WPF, .NET 4.0 and RadControls for WPF Q3 2010 SP1.  I'm trying to bind to a property on a view model that implements INotifyPropertyChanged, but it never seems to update the source.

On the xaml:
<telerik:RadDatePicker  HorizontalAlignment="Left"
                Margin="28,90,0,0"
                Name="radDatePicker1"
                VerticalAlignment="Top"
                Width="223"
                SelectedValue="{Binding Path=BoundDate}" />

On the view model:
/// <summary>
/// Gets the BoundDate property.
/// Changes to that property's value raise the PropertyChanged event.
/// This property's value is broadcasted by the Messenger's default instance when it changes.
/// </summary>
public DateTime BoundDate
{
    get
    {
        return _boundDate;
    }
 
    set
    {
        if (_boundDate == value)
        {
            return;
        }
 
        var oldValue = _boundDate;
        _boundDate = value;
 
        // Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
        RaisePropertyChanged(BoundDatePropertyName, oldValue, value, true);
    }
}

Thanks in advance,
Wyatt

3 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 20 Dec 2011, 11:29 AM
Hi Wyatt,

You need to set Mode=TwoWay in the Binding. The SelectedValue is not bound TwoWay by default.

Greetings,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Wyatt
Top achievements
Rank 1
answered on 20 Dec 2011, 03:10 PM
Great, that works correctly.

If this is working as intended, might I suggest putting it somewhere in the online documentation?  Also, as a general comment, it seems that most of the documentation is built around events in the code behind.  It would be very helpful (at least for me) if there were an equal amount of documentation built around binding in XAML.

Thanks,
Wyatt
0
Valeri Hristov
Telerik team
answered on 21 Dec 2011, 09:41 AM
Hi Wyatt,

Instead of putting this info in the documentation we would rather change the property to bind two way by default. This way the behavior will be intuitive and you will not need to dig in the documentation.

Regarding the events vs. bindings in the documentation - we are trying to keep some balance because many of our customers come from the WinForms and ASP.NET worlds and are not used to the WPF bindings and MVVM, hence they insist for examples with events...

Greetings,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
DatePicker
Asked by
Wyatt
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Wyatt
Top achievements
Rank 1
Share this question
or