Articles in this section
Category / Section

How can I prevent the pivotgrid from calling the loaded event before these properties are initialized

1 min read

The PivotGrid Loaded event was called before the PivotGrid gets initialized which leads the event to be deal with null InternalGrid and we hereby let you know that the properties of the GroupingBar or InternalGrid can be accessed only after the PivotGrid gets initialized. We have two solutions to prevent calling the Loaded Event prior to initialization of PivotGrid.

 

Calling the PivotGrid Loaded Event after InitializeComponent () gets called will resolve this issue as shown in below code:

C#

public MainWindow()
{ 
InitializeComponent();
this.pivotGrid1.Loaded += new RoutedEventHandler(pivotGrid1_Loaded);
}
 

 

We have a Dispatcher delegate Event Handler which allows the Event to be handled after the initialization. The code snippet for the same is shown below:

C#

public MainWindow()

{

this.Dispatcher.BeginInvoke((Action)delegate()

{

this.pivotGrid1.Loaded += new RoutedEventHandler(pivotGrid1_Loaded);

});

InitializeComponent(); }

 

 

 

C:\Users\labuser\Dropbox\Screenshots\Screenshot 2014-06-06 10.40.27.png

Figure: A properly loaded Pivot Grid

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied