共用方式為


How to Design a View

 

Applies To: System Center 2012 SP1

A view add-in is declared in a class that inherits from ViewAddInBase. The view add-in provides a control that is displayed in the Virtual Machine Manager (VMM) console. The following procedure demonstrates the steps that are required to create a view add-in and provides an example that you can reuse in your own code.

To create a new action add-in

  1. Create a new class that inherits from ViewAddInBase.

  2. Declare the T:System.Addin.AddinAttribute attribute on the class and give it a unique name.

  3. Mark the scope of the class as public.

  4. Override the CreateViewControl method to supply the console with a view.

  5. Optionally, override the GetButtonLabelString method to supply an alternative caption for the ribbon button.

  6. Optionally, override the SetScopeType method when you want to know if the console scope changes.

Example

The following code example provides a skeleton that you can use when you create a new add-in. You must change the type of control that is returned to your own view:

  
[AddIn("View Add-in 1")]  
public class MyViewAddIn : ViewAddInBase  
{  
    private Control _viewControl;  
  
    public override FrameworkElement CreateViewControl()  
    {  
        _viewControl = new Control();  
  
        return _viewControl;  
    }  
}  
  

Compiling the Code

Namespaces

System.Windows
System.Windows.Controls
Microsoft.SystemCenter.VirtualMachineManager.UIAddIns
System.AddIn

Assemblies

System.AddIn
PresentationFramework
Microsoft.SystemCenter.VirtualMachineManager.UIAddIns

See Also

Base Classes
User Interface Extension Overview
How to Define a View in the Manifest
How to Use Context Objects with a View [VMMUISDK]]