Hi All,
I have used one XMLfile as data source for my datagrid in a WPF.
XML:-
="1.0"="utf-8"
<Profiles>
<Profile Name="PGB570/120/600/120" Weight="19200" Bolt="42"/>
<Profile Name="PGB570/100/600/100" Weight="16400" Bolt="42"/>
<Profile Name="PGB570/70/600/70" Weight="13300" Bolt="36"/>
<Profile Name="PGB570/60/600/60" Weight="10300" Bolt="36"/>
<Profile Name="UC" Weight="8900" Bolt="30"/>
</Profiles>
And in my designer...
XAML:
<Window x:Class="TEST_APP.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="TEST_APP" Height="280" Width="574""
ResizeMode="CanMinimize">
<Window.Resources>
<XmlDataProvider x:Key="ProfileData" Source="Resources/ProfileList.xml" XPath="/Profiles/Profile"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<TabControl HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch">
<TabItem Header="Diagrid Diagonals">
<Grid>
<DataGrid x:Name="profileData" HorizontalAlignment="Center" Height="147" Margin="0,0,0,20" VerticalAlignment="Center" Width="283" DataContext="{StaticResource ProfileData}" ItemsSource="{Binding XPath=/Profiles/Profile}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Profile" Binding="{Binding XPath= @Name}"/>
<DataGridTextColumn Header="Max. Weight" Binding="{Binding XPath=@Weight}"/>
<DataGridTextColumn Header="Bolt Dia" Binding="{Binding XPath=@Bolt}"/>
</DataGrid.Columns>
</DataGrid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="303"/>
<ColumnDefinition Width="153"/>
<ColumnDefinition Width="91"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>
Everything works good in designer, and I can see the datagrid is populated with data. But on runtime its not loading, just an empty datagrid.
Please have a look and help me.
What I have tried:
The code worked very well on runtime also, but something happened now its not showing anything. That's why I am wondering!!.
I have tried modifying the XAML in different ways but no hope.Please consider as I am a begginer in WPF and XAML.