bovender framework
C# framework that implements MVVM and more
Bovender.Mvvm.ViewModels.ViewModelBase Class Referenceabstract
Inheritance diagram for Bovender.Mvvm.ViewModels.ViewModelBase:
Bovender.ExceptionHandler.ExceptionViewModel Bovender.HtmlFiles.HtmlFileViewModel Bovender.Mvvm.Messaging.MessageContent Bovender.Mvvm.ViewModels.EnumViewModel< T > Bovender.Mvvm.ViewModels.ProcessViewModelBase Bovender.UnitTests.Mvvm.TestViewModel Bovender.UserSettings.UserSettingsExceptionViewModel Bovender.UserSettings.UserSettingsViewModel

Public Member Functions

bool IsViewModelOf (object model)
 Determines whether the current object is a view model of a particular model object. More...
 
Window InjectInto< T > ()
 Injects the ViewModel into a newly created View and wires the RequestCloseView event. More...
 
Window InjectInto (Window view)
 Injects the view model into an existing view by setting the view's DataContext. More...
 
void InjectAndShowInThread< T > (IntPtr ownerForm)
 Creates a new thread that creates a new instance of the view T , sets its Forms owner and shows it modelessly. More...
 
void InjectAndShowInThread< T > ()
 Creates a new thread that creates a new instance of the view T and shows it modelessly. More...
 
void InjectAndShowDialogInThread< T > (IntPtr ownerForm)
 Creates a new thread that creates a new instance of the view T and shows it as a dialog. More...
 
abstract object RevealModelObject ()
 Returns the model object that this view model wraps or null if there is no wrapped model object. More...
 

Protected Member Functions

 ViewModelBase ()
 Does not allow public instantiation of this class. More...
 
virtual void OnPropertyChanged (string propertyName)
 
virtual bool CanCloseView ()
 
virtual void DoCloseView ()
 
CancellationToken Dispatch (Action action)
 Dispatches an action in the current synchronization context if one exists, or using the Dispatcher. More...
 

Properties

virtual string DisplayString [get, set]
 
bool IsSelected [get, set]
 
Dispatcher ViewDispatcher [get, set]
 
ICommand CloseViewCommand [get]
 
Dispatcher Dispatcher [get]
 Captures the dispatcher of the thread that the object was created in. More...
 
TaskScheduler SyncContext [get]
 

Events

EventHandler RequestCloseView
 Raised by the CloseView Command, signals that associated views are to be closed. More...
 
PropertyChangedEventHandler PropertyChanged
 

Detailed Description

Definition at line 29 of file ViewModelBase.cs.

Constructor & Destructor Documentation

Bovender.Mvvm.ViewModels.ViewModelBase.ViewModelBase ( )
inlineprotected

Does not allow public instantiation of this class.

Definition at line 272 of file ViewModelBase.cs.

Member Function Documentation

CancellationToken Bovender.Mvvm.ViewModels.ViewModelBase.Dispatch ( Action  action)
inlineprotected

Dispatches an action in the current synchronization context if one exists, or using the Dispatcher.

Parameters
actionAction to dispatch

Definition at line 321 of file ViewModelBase.cs.

void Bovender.Mvvm.ViewModels.ViewModelBase.InjectAndShowDialogInThread< T > ( IntPtr  ownerForm)
inline

Creates a new thread that creates a new instance of the view T and shows it as a dialog.

Use this to show dialogs during asynchronous operations.

Parameters
ownerFormHandle of the Forms window that the view should belong to.
Template Parameters
TView (descendant of Window).
Type Constraints
T :Window 
T :new() 

Definition at line 189 of file ViewModelBase.cs.

void Bovender.Mvvm.ViewModels.ViewModelBase.InjectAndShowInThread< T > ( IntPtr  ownerForm)
inline

Creates a new thread that creates a new instance of the view T , sets its Forms owner and shows it modelessly.

Use this to show views during asynchronous operations.

Parameters
ownerFormHandle of the Forms window that the view should belong to.
Template Parameters
TView (descendant of Window).
Type Constraints
T :Window 
T :new() 

Definition at line 143 of file ViewModelBase.cs.

void Bovender.Mvvm.ViewModels.ViewModelBase.InjectAndShowInThread< T > ( )
inline

Creates a new thread that creates a new instance of the view T and shows it modelessly.

Use this to show views during asynchronous operations.

Template Parameters
TView (descendant of Window).
Type Constraints
T :Window 
T :new() 

Definition at line 177 of file ViewModelBase.cs.

Window Bovender.Mvvm.ViewModels.ViewModelBase.InjectInto ( Window  view)
inline

Injects the view model into an existing view by setting the view's DataContext.

Parameters
viewView that shall be dependency injected.
Returns
View with current view model injected.

Definition at line 114 of file ViewModelBase.cs.

Injects the ViewModel into a newly created View and wires the RequestCloseView event.

Template Parameters
TView, must be derived from System.Windows.Window
Returns
View with DataContext set to the current ViewModel instance that responds to the RequestCloseView event by closing itself.
Type Constraints
T :Window 
T :new() 

Definition at line 102 of file ViewModelBase.cs.

bool Bovender.Mvvm.ViewModels.ViewModelBase.IsViewModelOf ( object  model)
inline

Determines whether the current object is a view model of a particular model object.

Returns false if either the model or the viewmodel's wrapped model object is null.

Parameters
modelThe model to check.
Returns
True if model is wrapped by this; false if not (including null objects).

Definition at line 77 of file ViewModelBase.cs.

abstract object Bovender.Mvvm.ViewModels.ViewModelBase.RevealModelObject ( )
pure virtual

Returns the model object that this view model wraps or null if there is no wrapped model object.

This is a method rather than a property to make data binding more difficult (if not impossible), because binding directly to the model object is discouraged. However, certain users such as a ViewModelCollection might need access to the wrapped model object.

Returns
Model object.

Implemented in Bovender.Mvvm.ViewModels.ProcessViewModelBase, Bovender.Mvvm.ViewModels.EnumViewModel< T >, Bovender.UserSettings.UserSettingsExceptionViewModel, Bovender.Mvvm.Messaging.MessageContent, Bovender.HtmlFiles.HtmlFileViewModel, Bovender.UserSettings.UserSettingsViewModel, and Bovender.UnitTests.Mvvm.TestViewModel.

Property Documentation

Dispatcher Bovender.Mvvm.ViewModels.ViewModelBase.Dispatcher
getprotected

Captures the dispatcher of the thread that the object was created in.

Definition at line 347 of file ViewModelBase.cs.

Event Documentation

EventHandler Bovender.Mvvm.ViewModels.ViewModelBase.RequestCloseView

Raised by the CloseView Command, signals that associated views are to be closed.

Definition at line 244 of file ViewModelBase.cs.


The documentation for this class was generated from the following file: