2016-04-11 20 views
0

Ben wpf. İç içe geçmiş bir datatemplatelike this layout (datatemplate başka bir datatemplate içinde) oluşturmaya çalışıyorum. Bir veri sayfası oluşturmayı ve ObservableCollection'da gerçekten iyi çalışan bir "Object A"'a bağlanmayı başardım. Şimdi Object B ve Object C sütunlarını görüntülemek için her Object A iç içe ObservableCollection iç içe olması gerekir. Ama bunu nasıl yapacağımı gerçekten bilmiyorum ve örnekler bulamıyorum.İç içe geçmiş veri sayfası (datatemplate içinde datatemplate) ile bir wpf şablonu nasıl oluşturulur?

Belki herkes bana bir ipucu verebilir?

Teşekkür ve Saygılarımızla, Marlene

cevap

0

Bir ListView veya ListBoxObject A bir koleksiyon görüntülemek için kullandığınız varsayarak (ObjectACollection arama sağlar) ve Object A (bu örnekte) ObjectBCollection ve ObjectCCollection adında özelliklere sahip olduğu şunun gibi bir şey yapabilirsiniz:

<UserControl xmlns:namespaceA="clr-namespace:MyProj.Models.ObjectANamespace" 
      xmlns:namespaceB="clr-namespace:MyProj.Models.ObjectBNamespace" 
      xmlns:namespaceC="clr-namespace:MyProj.Models.ObjectCNamespace" > 
    <ListBox ItemsSource="{Binding ObjectACollection}"> 
     <ListBox.ItemTemplate> 
      <DataTemplate DataType="namespaceA:ObjectA"> 
       <StackPanel Orientation="Horizontal"> 
        <ListBox ItemsSource="{Binding ObjectBCollection}"> 
         <ListBox.ItemTemplate> 
          <DataTemplate DataType="namespaceB:ObjectB"> 
           <TextBlock Text="{Binding ObjectBProperty}"/> 
          </DataTemplate> 
         </ListBox.ItemTemplate> 
        </ListBox> 
        <ListBox ItemsSource="{Binding ObjectCCollection}"> 
         <ListBox.ItemTemplate> 
          <DataTemplate DataType="namespaceC:ObjectC"> 
           <TextBlock Text="{Binding ObjectCProperty}"/> 
          </DataTemplate> 
         </ListBox.ItemTemplate> 
        </ListBox> 
       </StackPanel> 
      </DataTemplate> 
     </ListBox.ItemTemplate> 
    </ListBox> 
</UserControl> 
İlgili konular