me again: MVVM purists would say that you should never call a MessageBox.Show() from a ViewModel.
In my test application I have a central locator class where the view registers itself, and the ViewModel sends the message through the locator:
Code: Select all
method DisplayMessageBox( cCaption as string, cMessage as string ) as System.Windows.MessageBoxResult
local oMessageDisplay as IMessageDisplay
local oResult as System.Windows.MessageBoxResult
oMessageDisplay := self:MessageDisplay
if oMessageDisplay != null
oResult := oMessageDisplay:DisplayMessageBox( cCaption, cMessage )
else
oResult := System.Windows.MessageBoxResult.OK
endif
return oResult
property MessageDisplay as IMessageDisplay
get
var oMessageDisplay := ServiceContainer.GetInstance():GetService<IMessageDisplay>()
if oMessageDisplay == null
Debug.WriteLine( "no IMessageDisplay registered!" )
endif
return oMessageDisplay
end get
end property
Wolfgang