2016-10-11 114 views
0

如何在ListView內製作RowDetailsTemplate類似Datagrid列表查看RowDetailsTemplate

我想象中的我格的底部添加包含rowdetails封閉:

<ListView 
     Grid.Row="1" 
     x:Name="listView" 
     VirtualizingStackPanel.IsVirtualizing="True" 
     VirtualizingStackPanel.VirtualizationMode="Recycling" 
     ScrollViewer.IsDeferredScrollingEnabled="True" 
     dz:GridViewSort.AutoSort="True" 
     dz:VirtualListLoadingIndicator.IsAttached="True" Margin="0,0,0,-15" 
     ItemsSource="{Binding ListeArticles}" Grid.RowSpan="2"> 
     <ListView.View> 
      <GridView ColumnHeaderTemplate="{StaticResource ListViewColumnHeaderTemplate}"> 
       <GridViewColumn Width="60" DisplayMemberBinding="{Binding Data.Article.ART_NUM}" Header="Reference" dz:GridViewSort.PropertyName="Article.ART_NUM" /> 
       <GridViewColumn Width="120" DisplayMemberBinding="{Binding Data.Article.ART_LIB}" Header="Designation" dz:GridViewSort.PropertyName="Article.ART_LIB" /> 
       <GridViewColumn Width="120" DisplayMemberBinding="{Binding Data.Article.ART_PRIX}" Header="Prix" dz:GridViewSort.PropertyName="Article.ART_PRIX" /> 
      </GridView> 
     </ListView.View> 
    </ListView> 
    <StackPanel Grid.Row="2"> 
     <TextBlock Text="{Binding Data.Article.STOCK}" /> 
     <TextBlock Text="{Binding Data.Article.SOMETHINGELSE}"/> 
    </StackPanel> 

但如何通過行數據到StackPanel的內容?

回答

0

當選擇行爲什麼不使用SelectedArticle然後結合的StackPanel到這個SelectedArticle數據:

1.SelectedArticle:

public Article SelectedArticle 
    { 
     get 
     { 
      return _selectedArticle; 
     } 
     set 
     { 
      _selectedArticle = value; 
      OnPropertyChanged("SelectedArticle");  
     } 
    } 

2.Xaml:

<Grid > 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"></RowDefinition> 
     <RowDefinition Height="Auto"></RowDefinition> 
    </Grid.RowDefinitions> 
    <ListView 
    Grid.Row="0" 
    x:Name="listView" 
    VirtualizingStackPanel.IsVirtualizing="True" 
    VirtualizingStackPanel.VirtualizationMode="Recycling" 
    ScrollViewer.IsDeferredScrollingEnabled="True" 
    ItemsSource="{Binding ListeArticles}" SelectedItem="{Binding SelectedArticle}"> 
     <ListView.View> 
      <GridView > 
       <GridViewColumn Width="60" DisplayMemberBinding="{Binding ART_NUM}" Header="Reference" /> 
       <GridViewColumn Width="120" DisplayMemberBinding="{Binding ART_LIB}" Header="Designation" /> 
       <GridViewColumn Width="120" DisplayMemberBinding="{Binding ART_PRIX}" Header="Prix" /> 
      </GridView> 
     </ListView.View> 
    </ListView> 
    <StackPanel Grid.Row="1"> 
     <TextBlock Text="{Binding SelectedArticle.STOCK}" /> 
     <TextBlock Text="{Binding SelectedArticle.SOMETHINGELSE}"/> 
    </StackPanel> 
</Grid>