Here’s the XAML structure. You’ll see below that I’m subscribing to the Loaded event of the grid. But when the even fires, this.selectionGrid is still null – even in consequent layout updates it is still null, even though I can see the grid all populated.
I do use MEFedMVVM and MvvmLight, but I don’t see how it relates to this situation.
Any ideas why?
<Grid x:Name="LayoutRoot" Margin="2">
<toolkit:BusyIndicator IsBusy="{Binding IsBusy}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ContentPresenter
Visibility="{Binding Path=CurrentStep,Converter={StaticResource IntToVisibilityConverter}, ConverterParameter=1}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Select Equipment" Style="{StaticResource HeaderBlockStyle}" />
<ScrollViewer Grid.Row="1">
<sdk:DataGrid x:Name="selectionGrid" GridLinesVisibility="All" AlternatingRowBackground="White" ItemsSource="{Binding Path=AvailableEquipmentView}" AreRowDetailsFrozen="True"
AutoGenerateColumns="False" SelectionMode="Extended" RowDetailsVisibilityMode="Visible" LayoutUpdated="selectionGrid_LayoutUpdated" Loaded="selectionGrid_Loaded" LoadingRowGroup="selectionGrid_LoadingRowGroup">
You should remove the ContentPresenter. ContentPresenter are intended to display their Content property and not “manual” children.
I would also mention that you do not need to place controls into the BusyIndicator. The BusyIndicator will fill all available space so place it at the “bottom” of the Grid (below all other controls in xaml)