0

这是 XAML 结构。您将在下面看到我订阅了网格的 Loaded 事件。但是当偶数触发时,this.selectionGrid它仍然是null- 即使在随后的布局更新中它仍然是null,即使我可以看到网格全部填充。

我确实使用了 MEFedMVVM 和 MvvmLight,但我看不出它与这种情况有什么关系。

任何想法为什么?

<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">
4

1 回答 1

1

您应该删除 ContentPresenter。ContentPresenter 旨在显示其 Content 属性,而不是“手动”子项。

我还要提一下,您不需要将控件放入 BusyIndi​​cator。BusyIndi​​cator 将填充所有可用空间,因此将其放置在网格的“底部”(在 xaml 中的所有其他控件下方)

<Grid x:Name="LayoutRoot" Margin="2">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid Visibility="{Binding Path=CurrentStep,Converter={StaticResource IntToVisibilityConverter}, ConverterParameter=1}">
        <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">
    <! -- Other controls -->
    <toolkit:BusyIndicator IsBusy="{Binding IsBusy}">
</Grid>
于 2012-06-15T04:37:12.247 回答