Getting Error capturing PropertyChanged event on RadTabView

0 Answers 160 Views
TabView
Jessie
Top achievements
Rank 1
Jessie asked on 18 Feb 2022, 11:30 PM

I followed the suggestions found on the following ticket (Tab selection event in UI for Xamarin | Telerik Forums), however I am getting a null reference exception error at Xamarin.Forms.Platform.UWP.VisualElementTracker`2.OnPropertyChanged(Object sender, PropertyChangedEventArgs e) in D:\a\1\s\Xamarin.Forms.Platform.UAP\VisualElementTracker.cs:line 313

Xamarin.Forms.Platform.UWP.VisualElementTracker<System.__Canon,System.__Canon>.get_Element(...) returned null.


 

below is the event to command behavior setup

                        <telerikPrimitives:RadTabView.Behaviors>
                            <b:EventToCommandBehavior EventName="PropertyChanged" 
                                                      Command="{Binding CartTabViewPropertyChangedCommand}" 
                                                      EventArgsConverter="{StaticResource propertyChangedEventArgsConverter}" />
                        </telerikPrimitives:RadTabView.Behaviors>

 

the converter is very simple:


    class PropertyChangedEventArgsConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var propertyChangedEventArgs = value as PropertyChangedEventArgs;
            if (propertyChangedEventArgs == null)
            {
                throw new ArgumentException("Expected value to be of type PropertyChangedEventArgs", nameof(value));
            }
            return propertyChangedEventArgs;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }


then finally the command is defined as follows:


this.CartTabViewPropertyChangedCommand = new Command(async (e) =>
{
    PropertyChangedEventArgs eventArgs = e as PropertyChangedEventArgs;
    if (eventArgs != null && eventArgs.PropertyName == "SelectedItem")
    {
        if (_previousSelectedTab == 0 && _selectedTab > 0)
        {
            if (cart?.customer?.shipToAddress?.zipCode?.Length >= 5)
                await UpdateCart();
        }
    }
});

 

The error occurs in the update cart command almost exclusively at the asynchronous call to a WCF endpoint...  although it is not the endpoint creating the error. the error just coincides with the async call

Didi
Telerik team
commented on 23 Feb 2022, 01:45 PM | edited

Hi Jessie, 

Thank you for the provided code. I have tried to create a sample project but some parts are missing - the UpdateCart method. cart, customer, previousSelectedTab, etc.

From the provided stack trace the Telerik is not mentioned. The null ref exception can be thrown because of various reasons. If you can isolate the issue in a sample project and send it back to me, that could be of help in further researching the case. If you do not want to share the project in the forum, you can open a support ticket and attach the project to it. 

Also check whether the exception occurs only if the EventToCommandBehavior is used?

No answers yet. Maybe you can help?

Tags
TabView
Asked by
Jessie
Top achievements
Rank 1
Share this question
or