How To : Adding an Adapter
Contents |
[edit] Description
This document describes different methods for adding an adapter to your project, as well as how you delete an adapter.
Note Once you have added the adapter, you must also bind your View to your Model, by assigning the adapter to both an element of your View and element of your Model, using the properties on the Adapter tab to assign the adapter to a control (View), and the Adapter List property to assign the same adapter to a member of your class (Model).
[edit] Prerequisites
Understanding Adapters
Introduction to MVA
Understanding the Adapter Tab
[edit] Procedures
[edit] Adding an Adapter in the Solution Explorer
To add an adapter to your project:
- Right-click on the project and select Add Adapter.
- In the dialog box that's displayed, do the following:
- In Name, type a name for the adapter.
- In Adapter Type, click the arrow in the drop-down box and select the adapter type.
- If you are adding a connection adapter, click the arrow in the drop-down box and select the Connection Adapter adapter type.
- Next to Connection Type click the ellipsis button [...].
- In the Select Class dialog, select the Dependencies tab and navigate to the TypLib: ControlConnection project and choose the control for which you want your adapter to provide an interface.
- Click OK.
- Click OK.
- The adapter is added to the project and automatically selected.
[edit] Adding an Adapter from the Adapter Tab
Using this methodology both adds the adapter to your project and assigns the adapter to your View (control).
To add an adapter from the adapter tab
- In the Design Editor, select the control to which you want to assign an adapter.
- In the Property Editor, click the Adapter tab.
- In the column on the left, select the property category (Connections, Functions, Forms) of adapter you want to assign to the control.
- Select the property appropriate to the control behavior you want to govern (for instance, if you want to establish a behavior to handle when a user double-clicks the control, select the Double Click property).
- Add an adapter by clicking the ellipsis button [...].
Note Properties for connection adapters assign an adapter to the control by default. This default can be removed by clicking the clear adapter button, or you can change the default by following the steps below. You can also resestablish the default by clicking the Set Default Adapter button.
- In the Choose (adapter type) Adapter dialog, select Add a new (adapter type).
- In Name, type a name for the adapter.
- From the Choose A Project drop-down box, choose the project to which you want to add the adapter.
- Click OK.
[edit] Choosing an Adapter
Rather than adding a new adapter to your project, you can choose a pre-existing system provided adapter, or you can reuse an adapter you have previously created. The process of choosing an adapter also assigns the adapter to your View (control).
Note Once you have assigned the adapter to the control, you must also bind your View to your Model, by assigning the adapter to both an element of your View and element of your Model, using the properties on the Adapter tab to assign the adapter to a control (View), and the Adapter List property to assign the same adapter to a member of your class (Model).
To add an adapter from the adapter tab
- In the Design Editor, select the control to which you want to assign an adapter.
- In the Property Editor, click the Adapter tab.
- In the column on the left, select the property category (Connections, Functions, Forms) of adapter you want to assign to the control.
- Select the property appropriate to the control behavior you want to govern (for instance, if you want to establish a behavior to handle when a user double-clicks the control, select the Double Click property).
- Add an adapter by clicking the ellipsis button [...].
Note Properties for connection adapters assign an adapter to the control by default. This default can be removed by clicking the clear adapter button, or you can change the default by following the steps below. You can also resestablish the default by clicking the Set Default Adapter button.
- In the Choose (adapter type) Adapter dialog, select Add a new (adapter type).
[edit] Deleting an Adapter
To delete an adapter from your project:
- Select the adapter.
- Click the Delete icon (red X) at the top of the Solution Explorer.
[edit] Error Handling
[edit] Examples
See the Google Maps (or any other service-based) tutorial.
Below is an example of adding a connection adapter from the Solution Explorer.
[edit] Next Steps
Using Function Adapters
Add a connection to your class