UIVisualizerService
The IUIVisualizerService allows a developer to show (modal) windows or dialogs without actually referencing a specific view. Internally, the UIVisualizerService uses the ViewLocator to resolve views.
Framework | Supported |
---|---|
WPF | |
Silverlight 4 | |
Silverlight 5 | |
Windows Phone 7 | |
Windows Phone 8 | |
Windows RT | |
Test/emulation service |
Screenshot
Showing a non-modal window
To show a non-modal window, use the following code:
var viewModel = new EmployeeViewModel();
var uiVisualizerService = GetService<IUIVisualizerService>();
uiVisualizerService.Show(viewModel);
Showing a modal window
To show a modal window, use the following code:
var viewModel = new EmployeeViewModel(); var uiVisualizerService = GetService<IUIVisualizerService>(); uiVisualizerService.ShowDialog(viewModel);
Showing a window with callback
To show a (modal or non-modal) window and get a callback as soon as the window is closed, use the following code:
var viewModel = new EmployeeViewModel(); var uiVisualizerService = GetService<IUIVisualizerService>(); uiVisualizerService.Show(viewModel, OnWindowClosed);
Registering a window
To register a custom window which is not automatically detected via reflection, it is required to use the Register method:
var uiVisualizerService = GetService<IUIVisualizerService>(); uiVisualizerService.Register(typeof(EmployeeViewModel), typeof(EmployeeView));
Using naming conventions to find windows
Please see the ViewLocator topic.