binding external Xml with Xaml

Eluxury

New Member
i try to bind xml data to xaml--> it found the file but cann't extract the nodes or data from the file, it give me an empty list i try to get the name tag from the xml file which included in entry tag in feed tag
that's the xaml code:\[code\]<Grid.DataContext> <XmlDataProvider Source="bin\Debug\Weatherfile.xml" XPath="/feed/entry"></XmlDataProvider> </Grid.DataContext> <!--define the style of presentation and the source of data "Binding"--> <ListBox Grid.Row="0" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" > <ListBox.ItemContainerStyle > <Style TargetType="ListBoxItem"> </Style> </ListBox.ItemContainerStyle> </ListBox> <!--define lable--> <Label FontSize="25" Foreground="Red" Content="Watches, Warnings or Advisories for the United States" HorizontalAlignment="Right" Height="62" Margin="0,8,8,0" VerticalAlignment="Top" Width="611" d:LayoutOverrides="Margin"/> <!--define botton to get the xml file from the website and make node list of nodes--> <Button Content="Catch Alerts" HorizontalAlignment="Left" Margin="254,521,0,0" VerticalAlignment="Top" Width="124" Height="33" Click="Button_Click" d:LayoutOverrides="GridBox"/> <!--define data template which provide the listbox with the data it will present--> <Grid.Resources> <DataTemplate DataType="entry"> <Border Background="#2200FF00" BorderBrush="Black" BorderThickness="2" CornerRadius="8" Margin="2,4,2,4" Padding="4" > <!--define the tag it will present from the xml file--> <StackPanel HorizontalAlignment="Stretch"> <TextBlock FontWeight="Bold">Name:</TextBlock> <TextBlock Text="{Binding XPath=name}"/> </StackPanel> </Border> </DataTemplate> </Grid.Resources></Grid>\[/code\]
 
Back
Top