TrySetViewMode does change view on initial view

3 posts, 0 answers
  1. steve
    steve avatar
    6 posts
    Member since:
    Nov 2017

    Posted 03 Nov 2017 Link to this post

    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. steve
    steve avatar
    6 posts
    Member since:
    Nov 2017

    Posted 03 Nov 2017 in reply to steve Link to this post

    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

  3. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    844 posts

    Posted 06 Nov 2017 Link to this post

    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
Back to Top