Hi,
I have created a WPF application. I have a textbox in which I give input which is saved to database on button click, adjacently I have a Datagrid present which will populate the data in database. Now when I add new data it gets stored in database but is not reflected on datagrid.
I guess I will have to refresh the datagrid so I used DataGrid.Items.Refresh() but this does not work for my application.
Plz help how to solve this issue.
Thanks
Code Snippet:
private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
}
My datagrid gets bind as follows in wpf .xaml file :
<Window.Resources>
<XmlDataProvider Source="C:\Output.xml"
XPath="Data" x:Key="DataFile" />
</Window.Resources>
<DataGrid AutoGenerateColumns="False" Height="177" HorizontalAlignment="Left" Margin="322,62,0,0" Name="dgData" VerticalAlignment="Top" Width="149" ItemsSource="{Binding Source={StaticResource DataFile},XPath=*}">
<DataGrid.Columns>
<DataGridTextColumn Header="Type" Binding="{Binding XPath=@Type}" />
<DataGridTextColumn Header="Expense" Binding="{Binding XPath=@Value}" />
</DataGrid.Columns>
</DataGrid>
My XML looks as follows :
<Data>
<Record>
<Type>
ABC
</Type>
<Expense>
125
</Expense>
</Record>
<Record>
<Type>
DEF
</Type>
<Expense>
250
</Expense>
</Record>
</Data>
I just want to update the grid after the data is added to xml .