I am using a datagrid to display items from an SQLite DB, I have set my databinding as follows:
<Grid:SfDataGrid x:Name="gridOrderDetails" HorizontalAlignment="Left" Height="650" Margin="10,325,0,-15" VerticalAlignment="Top" Width="1420"
AutoGenerateColumns="False"
ScrollViewer.HorizontalScrollMode="Auto"
ScrollViewer.VerticalScrollMode="Auto"
IsDynamicItemsSource="True"
ItemsSource="{Binding OrderDetails}"
NavigationMode="Row">
public class vmOrderDetails
{
private ObservableCollection<dmOrderDetails> _orderDetails;
public ObservableCollection<dmOrderDetails> OrderDetails
{
get { return _orderDetails; }
set { _orderDetails = value; }
}
public vmOrderDetails()
{
_orderDetails = new ObservableCollection<dmOrderDetails>();
this.DisplayOrder();
}
private void DisplayOrder()
{
var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "cust.db");
using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
{
var itemDetailQry = from p in conn.Table<orderDetails>()
where p.ORDERNUMBER == DataClass.orderDetailOrderNumber
select new
{
ItemDesc = p.ITEMDESC,
ItemQty = p.ITEMQTY,
ItemCost = p.ITEMCOST,
ItemNum = p.ITEMNUM,
ItemStatus = p.ITEMSTATUS,
ItemSeq = p.ITEMSEQ,
ItemOrderNumber = p.ORDERNUMBER,
};
foreach (var d in itemDetailQry)
{
_orderDetails.Add(new dmOrderDetails(d.ItemSeq, d.ItemNum, d.ItemQty, d.ItemDesc, d.ItemCost, d.ItemStatus, d.ItemOrderNumber));
}
}
}
}
How can I run a function to refresh the data after I add a new item to the database?