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

Crash on UWP when using calendar in master/detail + modal navigation

2 Answers 106 Views
Calendar & Scheduling
This is a migrated thread and some comments may be shown as answers.
Valentin
Top achievements
Rank 1
Valentin asked on 24 Jul 2018, 02:12 AM

I'm using the calendar control in the master page of a master/detail scenario.When I perform a modal navigation to another page and then navigate back, the calendar crashes with this exception:

"System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.UI.Xaml.Controls.Input.Calendar.XamlHeaderContentLayer.MeasureContent(Object owner, Object content) at Telerik.UI.Xaml.Controls.Input.RadCalendar.Telerik.Core.IElementPresenter.MeasureContent(Object owner, Object content) at Telerik.UI.Xaml.Controls.Input.Calendar.CalendarMonthViewModel.GetCalendarViewRect(RadRect availableRect) at Telerik.UI.Xaml.Controls.Input.Calendar.CalendarMonthViewModel.Upd"

Am I doing something wrong?

Telerik_UI_for_Xamarin 2018.2.620.250
Shared code project targets .NET Standard 2.0
Xamarin Forms 2.5.1.527436
UWP

Here is the relevant code, simplified as much as possible:

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="RadCalendarBug.MasterDetailPage"
             xmlns:pages="clr-namespace:RadCalendarBug"
             x:Name="Self">
     
    <MasterDetailPage.ToolbarItems>
        <ToolbarItem Name="Settings" Order="Primary" Command="{Binding ShowSettingsCommand, Source={x:Reference Name='Self'}}" >
            <ToolbarItem.Icon>
                <OnPlatform x:TypeArguments="FileImageSource">
                    <On Platform="UWP" Value="Resources/Settings.png" />
                </OnPlatform>
            </ToolbarItem.Icon>
        </ToolbarItem>
    </MasterDetailPage.ToolbarItems>
    <MasterDetailPage.Master>
        <pages:MasterPage x:Name="MasterPage" />
    </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
        <NavigationPage>
            <x:Arguments>
                <pages:DetailPage />
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>
</MasterDetailPage>

 

Main.xaml.cs

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
 
namespace RadCalendarBug
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class MasterDetailPage : Xamarin.Forms.MasterDetailPage
    {
        public Command ShowSettingsCommand { private set; get; }
 
        public MasterDetailPage()
        {
            ShowSettingsCommand = new Command(ShowSettings, CanShowSettings);
 
            InitializeComponent();
        }
 
        private bool CanShowSettings(object arg)
        {
            return true;
        }
 
        private void ShowSettings(object obj)
        {
            Navigation.PushModalAsync(new NavigationPage(new Settings()));
        }
    }
}

 

MasterPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:telerikInput="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.XamarinForms.Input"
             x:Class="RadCalendarBug.MasterPage"
             Title="Master">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="500"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>
 
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
 
        <telerikInput:RadCalendar x:Name="calendar" />
        <Label Grid.Row="1" Text="BottomHalf" />
 
    </Grid>
</ContentPage>

 

MasterPage.xaml.cs

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
 
namespace RadCalendarBug
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class MasterPage : ContentPage
    {
        public MasterPage()
        {
            InitializeComponent();
        }
    }
}

 

DetailPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="RadCalendarBug.DetailPage"
             Title="Detail">
  <StackLayout Padding="10">
    <Label Text="This is a detail page. "/>
  </StackLayout>
</ContentPage>

 

DetailPage.xaml.cs

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
 
namespace RadCalendarBug
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class DetailPage : ContentPage
    {
        public DetailPage()
        {
            InitializeComponent();
        }
    }
}

 

Settings.xaml

<?xml version="1.0" encoding="utf-8" ?>
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="RadCalendarBug.Settings"
             x:Name="Self">
 
    <ContentPage.ToolbarItems>
        <ToolbarItem Name="Cancel" Order="Default" Command="{Binding CancelCommand, Source={x:Reference Name='Self'}}" Priority="1">
            <ToolbarItem.Icon>
                <OnPlatform x:TypeArguments="FileImageSource">
                    <On Platform="UWP" Value="Resources/Cancel.png" />
                </OnPlatform>
            </ToolbarItem.Icon>
        </ToolbarItem>
    </ContentPage.ToolbarItems>
 
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to Xamarin.Forms!"
                VerticalOptions="CenterAndExpand"
                HorizontalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

 

Settings.xaml.cs

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
 
namespace RadCalendarBug
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Settings : ContentPage
    {
        public Command CancelCommand { private set; get; }
 
        public Settings ()
        {
            CancelCommand = new Command(Cancel, CanCancel);
 
            InitializeComponent();
        }
 
        private bool CanCancel(object arg)
        {
            return true;
        }
 
        private void Cancel(object obj)
        {
            Navigation.PopModalAsync();
        }
    }
}

 

I'm not attaching the icons for the toolbar buttons but they're not really needed. Just click the ... button in the app bar to show the toolbar item text.

From the main page, click ..., then settings to navigate to the settings page. In the settings page, click ... then Cancel to go back. Note the exception.

Any pointers are appreciated.

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Didi
Telerik team
answered on 26 Jul 2018, 12:37 PM
Hi Valentin,

Thank you for the provided code.

I have tested it and I reproduced the issue with the RadCalendar control in UWP when MasterDetailPage is used. Currently, there is no suitable workaround I could suggest. 

I have logged this in our Feedback portal and you could follow the item to track its progress on the provided link below:
https://feedback.telerik.com/Project/168/Feedback/Details/254643-calendar-uwp-calendar-crashes-with-nullreferenceexception-when-masterdetailpag.

I would like to inform you that the bug is determined and fixed but the fix will be included in the next minor release (I mean not the minor release that will be available this week, but the one afterwards).

You can find your Telerik points updated for reporting this to us.

Regards,
Didi
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
Valentin
Top achievements
Rank 1
answered on 26 Jul 2018, 01:08 PM
Thank you for confirming the bug. Looking forward to the fix.
Tags
Calendar & Scheduling
Asked by
Valentin
Top achievements
Rank 1
Answers by
Didi
Telerik team
Valentin
Top achievements
Rank 1
Share this question
or