Sunday, July 28, 2013

How to manage two elements of xml file



<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<GridView SelectionChanged="gv1_selection_changed" Name="gv1" HorizontalAlignment="Left" Margin="66,51,0,0" VerticalAlignment="Top" Width="1241" Height="643" >
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Grid>
<Rectangle Fill="Blue" Tapped="Rectangle_Tapped"></Rectangle>
<TextBlock FontSize="25" Width="200" Height="200" Text="{Binding name}"></TextBlock>

</Grid>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>


</GridView>
<PopUp Name="pop" isOpen="False">
<TextBlock Name="tblock"/>
</PopUp>
</Grid>



protected async override void OnNavigatedTo(NavigationEventArgs e)
{
Windows.Storage.StorageFolder storagefolder = await
Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Common");
Windows.Storage.StorageFile storagefile = await storagefolder.GetFileAsync("XMLFile1.xml");
var stream = await storagefile.OpenAsync(Windows.Storage.FileAccessMode.Read);
XmlDocument doc = await XmlDocument.LoadFromFileAsync(storagefile);
XDocument xdoc = XDocument.Parse(doc.GetXml());
var item = from n in xdoc.Descendants("item")

select new
{
word= n.Element("name").Value,
meaning=n.Element("fathername").Value

};

gv1.ItemsSource = item;

}
gv1_selection_changed(Object Sender,TappedRoutedEventArgs e))
{
int i=gv1.SelectedIndex();
pop.isOpen=true;
tblock.text=n[i].fathername;
}



I want to display a pop up which displays the father name when we select a name. So tried the above code but its not working.So how can i do it?


No comments:

Post a Comment