Binding ObservableList's items properties in DataTemplate's Textblock

i want to use some of the MediaPlaybackItem properties(Artist , Title etc.) and bind them in the Listbox data template.Unfortunately MediaPlaybackItem can only access the meta of a song by calling MediaPlaybackItem.GetDisplayProperties().MusicProperties.Title;

In my ListView i have bind as a ItemSource observable list of MediaPlaybackItems :

 <ListView  x:Name="SongList" HorizontalAlignment="Left" Visibility="Visible" Height="773" Background="{Binding}"
                  Opacity="0.5" SelectedValue="selectedFile"
                  ItemsSource="{Binding MediaModels.ListOfMediaPlaybackItems , Mode=TwoWay , UpdateSourceTrigger=PropertyChanged}"

Then i have the ListView data template :

 <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Border BorderBrush="#404040" BorderThickness="0,0,0,2" HorizontalAlignment="Stretch"
                                Width="282" Height="80">
                            <Grid HorizontalAlignment="Left">
                                <TextBlock Text="{Binding MusicPropertiesTitle}" TextWrapping="WrapWholeWords"
                                           Margin="82,10,10,0" />
                                <Grid Margin="0,0,-140,0">
                                    <Image Source="Images/Album.png" Width="70" Height="70" Margin="0,0,350,0" />
                                </Grid>
                            </Grid>
                        </Border>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>

        </ListView>

I cannot find a way to bind each MediaPlaybackItem's property(MediaPlaybackItems .GetDisplayProperties().MusicProperties.Title;) to the TextBlock of the DataTemplate . I hope you understand what i want! Your help is Greatly appreciated!

Best regards

1 answer

  • answered 2017-06-17 18:56 Martin Nowak

    I never use mediaPlaybackItems but would load each property you want into a class and load the class into the observable collection if i understood what you want correctly. If you need help doing that let me know.