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

TrySetViewMode does change view on initial view

2 Answers 22 Views
This is a migrated thread and some comments may be shown as answers.
steve
Top achievements
Rank 1
steve asked on 03 Nov 2017, 03:31 PM

Hi, I'm creating a calendar control in xaml and ideally want to set the 'TrySetViewMode' (viewmode) in xaml but there doesnt seem a way to do this. I would like to bind it via a view model so i can switch the view to day/month etc.

For now i'm looking at just setting it int he content page code behind.

i've added the renderer as per the sample QR project.

xaml:

                <Controls:DayViewCalendar
                IsVisible="{Binding IsDayViewVisible}"
                AppointmentsSource="{Binding Appointments}"
                VerticalOptions="FillAndExpand"
                SelectedDate="{Binding SelectedDate, Mode=TwoWay}"   
                    
                x:Name="calendar" >
                    <Controls:DayViewCalendar.AppointmentsStyle>
                        <telerikInput:CalendarAppointmentsStyle DisplayMode="Shape" ShapeType="Ellipse"  />
                    </Controls:DayViewCalendar.AppointmentsStyle>
                </Controls:DayViewCalendar>

 

in the code behind i'm calling:

in contructor:

                InitializeComponent();
                calendar.TrySetViewMode(CalendarViewMode.Day);

 

But on run this still shows the month view and not day view. but if i hook up the CellTapped event and change in there is changes the view.

How can i get round this? and ideally how can I set this in XAML bound to a viewmodel?

regards

Steve

2 Answers, 1 is accepted

Sort by
0
steve
Top achievements
Rank 1
answered on 03 Nov 2017, 03:37 PM

solved the first part.. the calendar.

 

I've moved   the TrySetViewMode(CalendarViewMode.Day) tot he 'onappearing' and it now works fine.

looks like if it's not in the onappearing it doesnt call the renderer.

Still would like to do this using the ViewModel though and databinding

0
Lance | Manager Technical Support
Telerik team
answered on 06 Nov 2017, 04:03 PM
Hello Steve,

Please refer to the documentation here. You need to wait for the native control to finish loading before you can set the ViewMode. We recommend doing it in NativeControlLoaded because OnAppearing doesn't wait for all child controls to fully load.

Regards,
Lance | Tech Support Engineer, Sr.
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
Asked by
steve
Top achievements
Rank 1
Answers by
steve
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or