开发者

Clear datagrid in MVVM ViewModel

On my MVVM silverlight application I have a dataDrid (in the View) and the dataGrid ItemsSource is binding to a Domain Service Classes Sql stored procedure 'results' in the XAML file. The stored proc 'Results' is defin开发者_JS百科ed in ViewModel which calls the WCF's stored proc on a 'Model' class.

I need to erase all items on dataGrid when user clicks on 'Clear' button but the ViewModel did not have any object reference to the View (the UserControl) to re-set its binding.

I am able to set the dataGrid's ItemsSource to NULL to erase all items on dataGrid but I did not know how to make the 'binding' again later in 'ViewModel' when the 'Query' button is clicked. Is there any api to get the reference of 'UserControl' in 'View' from 'ViewModel'?

Thanks for any help.


If the grid has to be cleared, so should the ViewModel. The MVVM solution is to clear the collection in the ViewModel. The Grid will follow.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜