开发者

reloading or resetting the main window in WPF

I have a main window, which has a datagrid and link to import data. When the user clicks the link it should browse adn let the user selects the file to import.开发者_JAVA百科 And it opens another window to show the successfull importation of data to database.

Now I want to show the data in the datagrid in the main window. So basically i want to reset the main window so that it can show the imported data in WPF.

I have tried to call a internal function(of main window) to close() and initialize and bind the data to the data grid. But it doesn't work looks like.

Is there any easy way to do that?


depending on the way you have setup your databinding for the datagrid, you could simply call ResetBindings on the corresponding binding source.

so let's say you have a bindingsource b on your main window, and your datagrid or whatever control is bound to that bindingsource. the datasource property of b is set to some collection containig your data. if you want to "refresh" all controls bound to b, simply call ResetBindings on b.

you could also use a collection that implements IBindingList, which would notify your bindingsource if items are added, etc.


Just use a DataBinding and update the source. Are you using a serializable class that implements INotifyPropertyChanged? INotify must be implemented for it to work with data binding.

Also look into NavigationWindow and Pages. It makes it easy to have single window applications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜