coderushforroslyn-403133-coding-assistance-code-templates-xaf-templates.md
This topic describes templates you can use when you implement Controllers and Actions in eXpressApp Framework ( XAF ).
Important
Visual Studio IntelliSense has priority over CodeRush templates. For information on how to prioritize a CodeRush template over Visual Studio IntelliSense , refer to the following topic section: Expand a Template Instead of Visual Studio IntelliSense.
Template: xcv
public class MyViewController : ViewController
{
public MyViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
}
protected override void OnActivated()
{
base.OnActivated();
// Perform various tasks depending on the target View.
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();
}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
// Access and customize the target View control.
}
}
Public Class MyViewController
Inherits ViewController
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
' Perform various tasks depending on the target View.
End Sub
Protected Overrides Sub OnDeactivated()
' Unsubscribe from previously subscribed events and release other references and resources.
MyBase.OnDeactivated()
End Sub
Protected Overrides Sub OnViewControlsCreated()
MyBase.OnViewControlsCreated()
' Access and customize the target View control.
End Sub
End Class
Template: xcw
public class MyWindowController : WindowController
{
public MyWindowController() : base()
{
// Target required Windows (use the TargetXXX properties) and create their Actions.
}
protected override void OnActivated()
{
base.OnActivated();
// Perform various tasks depending on the target Window.
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();
}
}
Public Class MyWindowController
Inherits WindowController
Public Sub New()
MyBase.New()
' Target required Windows (use the TargetXXX properties) and create their Actions.
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
' Perform various tasks depending on the target Window.
End Sub
Protected Overrides Sub OnDeactivated()
' Unsubscribe from previously subscribed events and release other references and resources.
MyBase.OnDeactivated()
End Sub
End Class
Template: xcvod
public class MyDetailViewController : ObjectViewController<DetailView, BusinessObject>
{
public MyDetailViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
}
protected override void OnActivated()
{
base.OnActivated();
// Perform various tasks depending on the target View.
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();
}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
// Access and customize the target View control.
}
}
Public Class MyDetailViewController
Inherits ObjectViewController(Of DetailView, BusinessObject)
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
' Perform various tasks depending on the target View.
End Sub
Protected Overrides Sub OnDeactivated()
' Unsubscribe from previously subscribed events and release other references and resources.
MyBase.OnDeactivated()
End Sub
Protected Overrides Sub OnViewControlsCreated()
MyBase.OnViewControlsCreated()
' Access and customize the target View control.
End Sub
End Class
Template: xcvol
public class MyListViewController : ObjectViewController<ListView, BusinessObject>
{
public MyListViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
}
protected override void OnActivated()
{
base.OnActivated();
// Perform various tasks depending on the target View.
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();
}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
// Access and customize the target View control.
}
}
Public Class MyListViewController
Inherits ObjectViewController(Of ListView, BusinessObject)
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
' Perform various tasks depending on the target View.
End Sub
Protected Overrides Sub OnDeactivated()
' Unsubscribe from previously subscribed events and release other references and resources.
MyBase.OnDeactivated()
End Sub
Protected Overrides Sub OnViewControlsCreated()
MyBase.OnViewControlsCreated()
' Access and customize the target View control.
End Sub
End Class
Template: xcvd
public class MyDetailViewController : ViewController<DetailView>
{
public MyDetailViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
}
protected override void OnActivated()
{
base.OnActivated();
// Perform various tasks depending on the target View.
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();
}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
// Access and customize the target View control.
}
}
Public Class MyDetailViewController
Inherits ViewController(Of DetailView)
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
' Perform various tasks depending on the target View.
End Sub
Protected Overrides Sub OnDeactivated()
' Unsubscribe from previously subscribed events and release other references and resources.
MyBase.OnDeactivated()
End Sub
Protected Overrides Sub OnViewControlsCreated()
MyBase.OnViewControlsCreated()
' Access and customize the target View control.
End Sub
End Class
Template: xcvl
public class MyListViewController : ViewController<ListView>
{
public MyListViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
}
protected override void OnActivated()
{
base.OnActivated();
// Perform various tasks depending on the target View.
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();
}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
// Access and customize the target View control.
}
}
Public Class MyListViewController
Inherits ViewController(Of ListView)
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
' Perform various tasks depending on the target View.
End Sub
Protected Overrides Sub OnDeactivated()
' Unsubscribe from previously subscribed events and release other references and resources.
MyBase.OnDeactivated()
End Sub
Protected Overrides Sub OnViewControlsCreated()
MyBase.OnViewControlsCreated()
' Access and customize the target View control.
End Sub
End Class
XAF templates that create Actions are available when the caret is inside a custom controller’s method.
Template: xas
public class MyViewController : ViewController
{
SimpleAction action;
public MyViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
action = new SimpleAction(this, "MyAction", "View");
action.Execute += action_Execute;
}
private void action_Execute(object sender, SimpleActionExecuteEventArgs e)
{
// Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112737/).
}
//...
}
Public Class MyViewController
Inherits ViewController
Private action As SimpleAction
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
action = New SimpleAction(Me, "MyAction", "View")
AddHandler action.Execute, AddressOf action_Execute
End Sub
Private Sub action_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
' Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112737/).
End Sub
End Sub
End Class
Template: xac
public class MyViewController : ViewController
{
SingleChoiceAction action;
public MyViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
action = new SingleChoiceAction(this, "MyAction", "View");
action.ItemType = SingleChoiceActionItemType.ItemIsOperation;
action.Execute += action_Execute;
// Create some items
//action.Items.Add(new ChoiceActionItem("MyItem1", "My Item 1", 1));
}
private void action_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
{
var itemData = e.SelectedChoiceActionItem.Data;
// Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112738/).
}
//...
}
Public Class MyViewController
Inherits ViewController
Private action As SingleChoiceAction
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
action = New SingleChoiceAction(Me, "MyAction", "View")
action.ItemType = SingleChoiceActionItemType.ItemIsOperation
AddHandler action.Execute, AddressOf action_Execute
' Create some items
'action.Items.Add(New ChoiceActionItem("MyItem1", "My Item 1", 1))
End Sub
Private Sub action_Execute(ByVal sender As Object, ByVal e As SingleChoiceActionExecuteEventArgs)
Dim itemData = e.SelectedChoiceActionItem.Data
' Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112738/).
End Sub
End Class
Template: xap
public class MyViewController : ViewController
{
ParametrizedAction action;
public MyViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
action = new ParametrizedAction(this, "MyAction", "View", typeof(string));
action.Execute += action_Execute;
}
private void action_Execute(object sender, ParametrizedActionExecuteEventArgs e)
{
var parameterValue = (string)e.ParameterCurrentValue;
// Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112724/).
}
//...
}
Public Class MyViewController
Inherits ViewController
Private action As ParametrizedAction
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
action = New ParametrizedAction(Me, "MyAction", "View", GetType(string))
AddHandler action.Execute, AddressOf action_Execute
End Sub
Private Sub action_Execute(ByVal sender As Object, ByVal e As ParametrizedActionExecuteEventArgs)
Dim parameterValue = CType(e.ParameterCurrentValue, string)
' Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112724/).
End Sub
End Class
Template: xapw
public class MyViewController : ViewController
{
PopupWindowShowAction action;
public MyViewController() : base()
{
// Target required Views (use the TargetXXX properties) and create their Actions.
action = new PopupWindowShowAction(this, "MyAction", "View");
action.Execute += action_Execute;
action.CustomizePopupWindowParams += action_CustomizePopupWindowParams;
}
private void action_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
{
var selectedPopupWindowObjects = e.PopupWindowViewSelectedObjects;
var selectedSourceViewObjects = e.SelectedObjects;
// Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112723/).
}
private void action_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
{
// Set the e.View parameter to a newly created view (https://docs.devexpress.com/eXpressAppFramework/112723/).
}
//...
}
Public Class MyViewController
Inherits ViewController
Private action As PopupWindowShowAction
Public Sub New()
MyBase.New()
' Target required Views (use the TargetXXX properties) and create their Actions.
action = New PopupWindowShowAction(Me, "MyAction", "View")
AddHandler action.Execute, AddressOf action_Execute
AddHandler action.CustomizePopupWindowParams, AddressOf action_CustomizePopupWindowParams
End Sub
Private Sub action_Execute(ByVal sender As Object, ByVal e As PopupWindowShowActionExecuteEventArgs)
Dim selectedPopupWindowObjects = e.PopupWindowViewSelectedObjects
Dim selectedSourceViewObjects = e.SelectedObjects
' Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112723/).
End Sub
Private Sub action_CustomizePopupWindowParams(ByVal sender As Object, ByVal e As CustomizePopupWindowParamsEventArgs)
' Set the e.View parameter to a newly created view (https://docs.devexpress.com/eXpressAppFramework/112723/).
End Sub
End Class
See Also