none
Pivot SelectedItem property is causing crash in Windows UWP

    Question

  • As shown in the below code i have used a pivot control to display data and in the selection changed of pivot control i have called a method so that it will select the header value dynamically and displays the data.

    XAML Code:

        <Pivot x:Name="pivot" SelectionChanged="BindData">
              <PivotItem Header="Test1"></PivotItem>
              <PivotItem Header="Test2"></PivotItem>
        </Pivot>

    C# Code:

        private async void BindData(object sender, SelectionChangedEventArgs e)
        {
             dynamic selectedValue = pivot.SelectedItem;
        if (selectedValue != null)
            {
                            PropertyInfo pi = selectedValue.GetType().GetProperty("Header");
                            string sectionName = (String)(pi.GetValue(selectedValue, null));
        }
        }

    The code is working seamlessly fine in the Debug mode, but causing a crash in the release mode.
    What might be the issue for this? Any workaround? or any settings i am missing?
    Kindly help me on this issue.
    Thank you. 
      
    Thursday, May 18, 2017 12:25 PM