Navigation:  Application Architecture > Putting it All Together > Designing an Application Component >

Creating the View

Previous pageReturn to chapter overviewNext page

Now that we have a presentation model in the form of our TextEditorComponent, we need to create a view that implements the user-interface we have already designed.  In ClearCanvas, views are never created explicitly but are always defined in terms of an extension point (this is so that different views, in different windowing toolkits, can be created for the same component).  Let’s define an extension point for our view:

 

[ExtensionPoint()]

public class TextEditorComponentViewExtensionPoint : ExtensionPoint<IApplicationComponentView>

{

}

 

Note the name of the extension point.  This is the preferred naming convention for application component view extension points: for component XComponent, the extension point should be named XComponentViewExtensionPoint.

Now that we have defined an extension point for our view, we need to tell the framework to associate views of this kind with our component.  This is accomplished using the AssociateViewAttribute, which we will add to the declaration of our component class:

 

[AssociateView(typeof(TextEditorComponentViewExtensionPoint))]

public class TextEditorComponent

{

   ...

}

 

Note that AssociateViewAttribute takes a single parameter, which is the type that defines the view extension point.  With this attribute in place, the framework knows that when it encounters a component of type TextEditorComponent, it should create a view that is an extension of TextEditorComponentViewExtensionPoint.