So, I am trying to bind to a list in a ListView element, but I cannot force to bind it correctly. If someone can help me with a fixed binding, that would be great!
Here is the source you are likely to need:
//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; } }
XAML I'm trying to fix below
<ListView Name="finishedView" ItemsSource="{Binding UploadedAnime}"> <ListView.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="AnimeExpander.xaml"/> </ResourceDictionary.MergedDictionaries> <DataTemplate x:Key="AnimeRow"> <DockPanel> <Expander Template="{StaticResource AnimeExpanderControlTemplate}" Header="{Binding AnimeTitle}"> <Expander.ContentTemplate> <DataTemplate> <Border BorderBrush="Black" BorderThickness="1,1,1,1"> <ListView ItemsSource="{Binding Path=Episodes}"> <ListViewItem> <DockPanel> <TextBlock Text="{Binding Title}" DockPanel.Dock="Left" /> </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>
If you need any other source code, please let me know. Many thanks!
Josh source share