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

Using x:Bind with TwoWay mode for SelectedDateRange doens't work

6 Answers 51 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
SkyBlue
Top achievements
Rank 1
SkyBlue asked on 04 Mar 2019, 07:59 AM

<telerikInput:RadCalendar SelectedDateRange="{x:Bind DataRange,Mode=TwoWay}" DisplayMode="MonthView" SelectionMode="Multiple"/>

 

public sealed partial class MainPage : Page
    {

        private CalendarDateRange? dateRange = new CalendarDateRange(new DateTime(2019,3,1),new DateTime(2019,3,20));
        public CalendarDateRange? DataRange
        {
            get => dateRange;
            set
            {
                dateRange = value;
            }
        }
        public MainPage()
        {
            this.InitializeComponent();
        }
    }

 

My question is how to do the selection operation on this control that will change the DataRange property value correctly? For now, the startdate and enddate always are the same value when I do the selection on the control.

6 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 05 Mar 2019, 03:53 PM
Hello Mo,

I've just tested the provided snippet it works properly on my side. Please note that SelectedDateRange holds a reference to the first date range in the current selection.  So, if you're added another selection range, this property will not be updated - in this case you would need to use SelectedDateRanges property. For more detailed information on this, refer to the Calendar: Selection topic in our documentation.

I've also attached my test project for a reference.

Let me know if you have any additional questions on this.

Regards,
Yana
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
0
SkyBlue
Top achievements
Rank 1
answered on 06 Mar 2019, 08:06 AM
I meant that if I select 2019-3-10, the DataRange value will be updated, but the startDatea and endDate are the same 2019-3-10. Is it the correct behavior?
0
Yana
Telerik team
answered on 11 Mar 2019, 02:45 PM
Hi Mo,

I am sorry I wasn't able to reply earlier.

If the new DateRange contains only one date, that would be the expected behavior.  Do you find any drawbacks with that approach?

Regards,
Yana
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Perry
Top achievements
Rank 1
answered on 23 Apr 2019, 05:53 AM
Two way binding seems to not update the view unless you type in a text field. Like most date pickers it pops up a calendar to select your date.
0
Perry
Top achievements
Rank 1
answered on 24 Apr 2019, 06:25 AM
vidmate
0
Yana
Telerik team
answered on 24 Apr 2019, 11:26 AM
Hi Perry,

First, you'd need to implement INotifyPropertyChanged in order to update the view through two-way binding and then, the SelectedRange  should be in the currently visible month.

I have attached the updated sample to show you how this would work.

I hope I was of help.

Regards,
Yana
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Calendar
Asked by
SkyBlue
Top achievements
Rank 1
Answers by
Yana
Telerik team
SkyBlue
Top achievements
Rank 1
Perry
Top achievements
Rank 1
Share this question
or