我添加ContentPresenter
后,Click="btnAdd_Click"
中的GridViewColumn
给出了null异常错误,并且无法加载窗口。
WPF:
<ContentPresenter Content="{Binding}">
<ContentPresenter.ContentTemplate>
<DataTemplate>
<Grid>
<ListView Name="productList" ItemsSource="{Binding Path=ProductList}" Height="200">
<ListView.View>
<GridView>
<GridView.ColumnHeaderContainerStyle>
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation ="Horizontal">
<Button x:Name="btnOfflineAdd"
Tag="{Binding Index}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontFamily="Segoe WP"
Content="+"
Height="30" Width="25"
Click="btnAdd_Click" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
...
</Grid>
</DatTemplate>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=ProductList.Count}" Value="0">
<Setter TargetName="productList" Property="Visibility" Value="Collapsed"/>
<Setter TargetName="productListEmpty" Property="Visibility" Value="Visible"/>
</DataTrigger>
</DataTemplate.Triggers>
</ContentPresenter.ContentTemplate>
</ContentPresenter>