J'essaie de me lier à une liste dans un élément ListView mais je n'arrive pas à obtenir une liaison correcte. Si quelqu'un pouvait m'aider à corriger cette liaison, ce serait formidable !
Voici la source dont vous aurez probablement besoin :
//class that xaml is initially bound to
public partial class UploadMngPanel : Grid
{
....
//initial list to bind to
public ObservableCollection<FinishedAnimeCollection> UploadedAnime
{
get { return uploadedAnime; }
}
}
public class FinishedAnimeCollection
{
...
//second list to bind to
private ObservableCollection<AnimeEpisodeItem> _episodes = new ObservableCollection<AnimeEpisodeItem>();
public ObservableCollection<AnimeEpisodeItem> Episodes
{
get { return _episodes; }
}
}
public class AnimeEpisodeItem
{
public String Title { get; set; }
public DateTime TimeAdded { get; set; }
}
Le XAML que j'essaie de corriger est le suivant
<!-- First list binding here (this works)-->
<ListView Name="finishedView" ItemsSource="{Binding UploadedAnime}">
<ListView.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="AnimeExpander.xaml"/>
</ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="AnimeRow">
<DockPanel>
<!-- <Image Height="75" Width="Auto" Source="{Binding Image}" DockPanel.Dock="Left" VerticalAlignment="Top"/> -->
<Expander Template="{StaticResource AnimeExpanderControlTemplate}" Header="{Binding AnimeTitle}">
<Expander.ContentTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="1,1,1,1">
<!--Second list binding here (this doesn't work)-->
<ListView ItemsSource="{Binding Path=Episodes}">
<ListViewItem>
<DockPanel>
<TextBlock Text="{Binding Title}" DockPanel.Dock="Left" />
<!--<TextBlock Text="{Binding TimeAdded}" DockPanel.Dock="Right" />-->
</DockPanel>
</ListViewItem>
</ListView>
</Border>
</DataTemplate>
</Expander.ContentTemplate>
</Expander>
</DockPanel>
</DataTemplate>
</ResourceDictionary>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Width="700" Header="Anime" CellTemplate="{StaticResource AnimeRow}"/>
</GridView>
</ListView.View>
</ListView>
Si vous avez besoin de plus de code source, faites-le moi savoir. Merci beaucoup !