I'm trying XElement binding for the very first time so apologies if this is very silly. I have an XML which I need to bind to DataGrid.
Music.xml:
<Music>
<Album Title="Chris Sells Live" Artist="Chris Sells" ReleaseDate="2/5/2008" />
<Album Title="The Road to Redmond" Artist="Luka Abrus" ReleaseDate="4/3/2008"/>
<Album Title="The Best of Jim Hance" Artist="Jim Hance" ReleaseDate="6/2/2008"/>
</Music>
CodeBehind :
InitializeComponent();
XElement MyMusic = XElement.Load("Music.xml");
this.XElementContainer.DataContext = MyMusic.Elements("Album");
Above code gets the XElement from Music.Xml file
XAML :
<DataGrid x:Name="XElementContainer" ItemsSource="{Binding}"/>
OutputWindow.jpg - Google Drive
The above link contains the output of the current execution where it is binding the properties of XElement.I need to bind the child element of specified node i.e Album which has child nodes of Title, Artist and Release Date.
As you see the image, why is it Binding Properties of XElement? How do i get rid of this?
I'm expecting the output in datagrid where I dont want to create any static DataGridTextColumn. Is it possible to just bind the XElement data and get a result like this:
Title |Artist |ReleaseDate
Chris Sells Live Chris Sells 2/5/2008
the Road to Redmond Luka Abrus 4/3/2008
the Best of Jim Hance Jim Hance 6/2/2008
What I have tried:
I'm very new to XElement binding. so what ever posted above is what I have tried.