Binding Issue (v2010.3.1314.40)

4 posts, 1 answers
  1. Wyatt
    Wyatt avatar
    2 posts
    Member since:
    Jun 2011

    Posted 19 Dec 2011 Link to this post

    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
  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 20 Dec 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Wyatt
    Wyatt avatar
    2 posts
    Member since:
    Jun 2011

    Posted 20 Dec 2011 Link to this post

    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
  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 21 Dec 2011 Link to this post

    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 >>

Back to Top