C# Class System.Windows.Controls.ViewModelAttribute

Inheritance: System.Attribute
ファイルを表示 Open project: nikhilk/silverlightfx

Public Methods

Method Description
CreateViewModel ( System.Windows.Controls.UserControl userControl ) : object

Creates a view model for the specified view. This uses the view model type specified using a ViewModelAttribute if one is specified, and falls back to convention. The convention locates a type in the same namespace/assembly as the view, with a type name formed by adding the 'Model' or 'ViewModel' suffix to the view's type name.

GetCurrentViewModel ( FrameworkElement element ) : object

Gets the model associated with the specified framework element. This will walk up the parent hierarchy to find a model if the specified element does not have a model.

GetViewModel ( System.Windows.Controls.UserControl userControl ) : object

Gets the view model instance attached to the specified control.

SetViewModel ( System.Windows.Controls.UserControl userControl, object value ) : void

Sets the view model instance attached to the specified control. The view model is also used as the DataContext assigned to the control.

ViewModelAttribute ( Type viewModelType ) : System

Initializes an instance of a ViewModelAttribute.

Method Details

CreateViewModel() public static method

Creates a view model for the specified view. This uses the view model type specified using a ViewModelAttribute if one is specified, and falls back to convention. The convention locates a type in the same namespace/assembly as the view, with a type name formed by adding the 'Model' or 'ViewModel' suffix to the view's type name.
public static CreateViewModel ( System.Windows.Controls.UserControl userControl ) : object
userControl System.Windows.Controls.UserControl The control for which the view model must be created.
return object

GetCurrentViewModel() public static method

Gets the model associated with the specified framework element. This will walk up the parent hierarchy to find a model if the specified element does not have a model.
public static GetCurrentViewModel ( FrameworkElement element ) : object
element System.Windows.FrameworkElement The element to lookup.
return object

GetViewModel() public static method

Gets the view model instance attached to the specified control.
public static GetViewModel ( System.Windows.Controls.UserControl userControl ) : object
userControl System.Windows.Controls.UserControl The control to lookup.
return object

SetViewModel() public static method

Sets the view model instance attached to the specified control. The view model is also used as the DataContext assigned to the control.
public static SetViewModel ( System.Windows.Controls.UserControl userControl, object value ) : void
userControl System.Windows.Controls.UserControl The control to associated the view model with.
value object The view model instance.
return void

ViewModelAttribute() public method

Initializes an instance of a ViewModelAttribute.
public ViewModelAttribute ( Type viewModelType ) : System
viewModelType System.Type The type of the associated view model.
return System