Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF and C# - Gridview Row selection and XML Datasource - how to make the connection?
    primarykey
    data
    text
    <p>I have a GridView defined like this :-</p> <pre><code>&lt; ListView Name="chartListView" SelectionChanged="chartListView_SelectionChanged"&gt; &lt; ListView.View&gt; &lt; GridView&gt; &lt; GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" Width="250"/&gt; &lt; GridViewColumn Header="Type" DisplayMemberBinding="{Binding Type}" Width="60"/&gt; &lt; GridViewColumn Header="Default Font" DisplayMemberBinding="{Binding defaultFontName}" Width="100"/&gt; &lt; GridViewColumn Header="Size" DisplayMemberBinding="{Binding defaultFontSize}" Width="40"/&gt; &lt; GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}" Width="100"/&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; </code></pre> <p>and I populate the GridView with an XML datasource like this</p> <pre><code>XDocument xml = XDocument.Load(@"D:\devel\VS\pchart\charts.xml"); var query = from p in xml.Elements("charts").Elements("chart") select p; foreach (var record in query) { chartListView.Items.Add(new { Name = record.Attribute("Name").Value, Type = record.Attribute("Type").Value, defaultFontName = record.Attribute("defaultFontName").Value, defaultFontSize = record.Attribute("defaultFontSize").Value, ID = record.Attribute("ID").Value }); } </code></pre> <p>My question is, when a user clicks on a row in the GridView, and the function chartListView_SelectionChanged is triggered, how do select the corresponding record in my XML datasource, so that I can manipulate the correct/selected data?</p> <p>Thanks, Will.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload