Welcome Guest! To enable all features please Login or Register.



How to map a logical type to a WPF control
#1 Posted : Sunday, September 2, 2012 5:44:02 PM(UTC)

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.
  1. 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"
  2. 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.
  3. 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.
  4. If your control should be used in data grids instead of a generic label then set the use-in-grid attribute to true.
  5. Inside the ui:control element add the XML definition of the WPF control in the corresponding namespace("http://schemas.microsoft.com/winfx/2006/xaml/presentation") with all the attributes as needed.
  6. 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.
<module xmlns="http://www.xomega.net/omodel" xmlns:ui="http://www.xomega.net/ui">
    <type name="invoice type" base="enumeration">
          <ComboBox Style="{StaticResource ControlStyle}" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"/>
        <ui:control multi-value="true">
          <ListBox Style="{StaticResource ControlStyle}" MaxHeight="58" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"/>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Copyright © 2009-2022 Xomega.Net. All rights reserved.