I have what I consider to be a stupid problem with a simple Silverlight application that has a datagrid in it. One of my columns lets the user edit an attendance number for the current day. if the user tabs/clicks away after editing, all is saved and good with the binding contract, but if the datagrid edit box has focus and the user closes the browser, the data is not updated in the database. I am using Silverlight 4 with a开发者_如何学编程n observable collection through the standard wcf ria services.
Any ideas what I can do?
In your App.xaml.cs there is an Application_Exit() function. That function is launched event when the user closes the browser.
in that method, retrieve your current opened window through the RootVisual like that :
private void Application_Exit(object sender, EventArgs e)
{
if (this.RootVisual is MySLApp.MainPage)
{
MySLApp.MainPage theMainPage = (MySLApp.MainPage)this.RootVisual;
theMainPage.myGrid.Commit() // OR SOMETHING LIKE THAT I DONT THINK THE COMMIT EXISTS :)
}
}
精彩评论