In order to support generation of WPF and Silverlight forms, the logical types of the parameters that are used to generate the form fields should be mapped to a corresponding WPF control. There could be different mappings for different scenarios, e.g. when the field may allow multiple values or a single value, so that the most appropriate control can be used, such as a ListBox vs. a ComboBox.
Normally if you extend your logical type from another base type in the model, it will automatically inherit the mapping to the WPF controls from its parent. If your type does not extend any other logical type, or you just want to override the mapping to the WPF controls , then the following steps outline this process.
- Make sure that the module element that contains your logical type declares a prefix for the "http://www.xomega.net/ui" namespace, e.g. xmlns:ui="http://www.xomega.net/ui"
- Add a ui:control element inside of the config element of your logical type definition. In the absence of such element your logical type will just inherit the WPF control from its base type if one exists.
- If your control should be used only when the property supports multiple values being selected or entered then set the multi-value attribute to true.
- If your control should be used in data grids instead of a generic label then set the use-in-grid attribute to true.
- Inside the ui:control element add the XML definition of the WPF control in the corresponding namespace("http://schemas.microsoft...x/2006/xaml/presentation") with all the attributes as needed.
- To validate your setup find a parameter that uses your logical type and is included in generation of a WPF or Silverlight form, and then generate the form and check the control used for the corresponding field.
Here is a sample configuration that illustrates these steps.
Code:
<module xmlns="http://www.xomega.net/omodel" xmlns:ui="http://www.xomega.net/ui">
<types>
<type name="invoice type" base="enumeration">
<config>
<ui:control>
<ComboBox Style="{StaticResource ControlStyle}" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"/>
</ui:control>
<ui:control multi-value="true">
<ListBox Style="{StaticResource ControlStyle}" MaxHeight="58" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"/>
</ui:control>
</config>
</type>
</types>
</module>