Cabuxa.Mapache
Cabuxa.Mapache

Reputation: 771

Bind Pivot SelectedIndex causes app random crash Windows Phone 8.1 Universal app

I have an universal app for WP 8.1 with a page and a Pivot in it. The "SelectedIndex" property of the pivot is bind to a property in the VM like this:

public object SelectedPivotIndex
{
    get { return this.selectedPivotIndex; }
    set
    {
        if (this.selectedPivotIndex == value) return;
        this.selectedPivotIndex = value;
        RaisePropertyChanged(() => SelectedPivotIndex);
    }
}

Page code:

<Pivot x:Name="ContentPivot"
        x:Uid="ContentPivot"
        SelectedIndex="{Binding SelectedPivotIndex, Mode=TwoWay}"
    >...</Pivot>

The problem is from time to time i'm having app crash (in App.xaml.cs): "Unhandled exception" with type "COMEXCEPTION". This crash stop if I remove the bind of the "SelectedIndex" in the xaml, but I cannot understand why it ocurs. Sometimes even the debugger is not shown and the app closes without any error information. BTW I'm using MVVM Light, so the "glue" between the view (page) and the VM is set in the page:

<Page
...
DataContext="{Binding Source={StaticResource Locator}, Path=Main}"
>

EDIT:

I'm able to reproduce the crash with this behavior: Open app, navigate to another page, come back to the pivot page (several times) and flip throught the pivotitems.

Upvotes: 1

Views: 543

Answers (1)

Robert Hedgate
Robert Hedgate

Reputation: 76

I have had the same issue. Solved it by hadling the selected changed event instead. Not a solution but a workaround.

Upvotes: 1

Related Questions