Keep up to date with the Symphony Framework by subscribing to the mailing list.

Check out the new Symphony Framework Academy! It’s the home for information and tutorials to help you get the most from the Symphony Framework! Click on the Academy option below.

Symphony Framework Development

Symphony Framework Synergy Decimal Field Overview.


A Synergy Decimal field stores numeric data. The amount of storage available is determined by its size. A Synergy decimal field is designed to store a whole number, positive or negative. However, many Synergy applciations store values in decimal fields but require that the display and input capabilities are presented as though the field allows a precision. The Symphony Framework accomodates this requirement and you can determine how a decimal field is presented by setting attributes against the field.

You should define a prompt value for your Decimal fields. Prompts are used in the UI to define field labels and report headings (you can also define a report heading, see below). Do not include special characters like > and <. If you need these in the prompt you must escape the character. The following table shows the escaped values:
Character Syntax Description


Using the Synergy Repository, Symphony Framework templates, and CodeGen you can build powerful user interface styles, user controls and windows. All field entry controls utilise styles. A style defines how the user control will be rendered on the user interface. They also provide the ability to enable and display field/prompt entities, provide error state information and control input focus.

When you utilise the Synergy Repository and the CodeGen utility with the Symphony Framework templates to generate the styles for your user interface controls the templates utilise the fields and attributes defined in your repository. When processing a field there are a number of styles produced. The different styles allow you to accommodate a number of different scenarios in your Windows Presentation Foundation applications.

Decimal fields are exposed as a Symphony Framework SynergyDecimalBox. This allows entry of only numeric characters, up to the maximum size of the associated field. If a decimal field allows a negative value then then a single negative sign is allowed. The following table defines the Synergy Repository field attributes that are recognised by the Symphony Framework CodeGen templates.

Attribute Comment
Size Will limit the number of character that can be entered into the field. If the field allows negative values and a precision, this will be reflected in the number of characters that can be enterd.
Exclude by Language Prevents the field being exposed through the Symphony Data Object. This is useful for hiding large/complex array and group elements. If you want the field available, but not exposed as a property then you should define the field with the token in the long description. See the long description tokens section below
Exclude by Toolkit Prevents the field from being included in any view or DataGrid. No style is created for the field. It will still be available as a property in the Data Object.
Exclude by Report Writer Will exclude the field from any criteria selection windows. This prevents the user from being able to see/use this field to select records in the data source. Fields will also not be available for inclusion by the user within DataGrid views. It will still be available as a property in the Data Object.
Prompt Used to propagate the fields associated Label style. As per the rules defined by CodeGen, if this attribute is not defined the field name will be used.
Report Heading Will populate the DataGrid column heading is specified. As per the rules defined by CodeGen, if this attribute is not defined the field prompt will be used.
View as
Field. Display the standard synergyDecimalBox.
Checkbox. Will convert the field’s style to that of a CheckBox control. The values assigned to the field will be “1” for checked, and “0” for unchecked.
Radio Button. Will create a radio button group. The values within the group will be the values of the Selection – List entries.
Action-Default You can define a default value. When a Data Object is initialised, default values will be assigned to the associated fields..
Break Forces the entered data to update the data bound property as the data is changed, not when the field has lost focus. Note: Due to a current limitation in the Microsoft Framework 4.0 this setting is currently ignored and ALL fields are defined to update bound data when the property changes.
Required The field will be in error until at least one character is entered.
Allow negative The field will allow the entry of the negative sign to indicate a negative value being enterd/displayed.
Selections
List. Assigns a Combo drop down list to the field’s style. The entries within the list are used to define the available dropdown list items. The field value for each item will be determined by it's ordinal position unless you define the field as enumerate:.
Window. Assigns a Combo drop down list to the field’s style. The name of the selection window must be that of the repository structure that contains the value/description pairs. You can then code generate the code to load the selections from the file associated to the structure.
Hyperlink Method Will display the fields associated label as a HyperLinkLabel that can be clicked by the user, and a new visual state presented.

Long Description tokens


There are a number of tokens that can be defined in the long description for a field that will alter the code generated. the following table lists all possible tokens and their associated actions. All tokens are defined within < and > characters.

Token Action
SYMPHONY_ARRAY_FIELD This token identifys the field as an arrayed field which is to be excluded from the property list of the Data Object. When CodeGen encounteres an arrayed field it flattens the field and creates individual properties/fields for each element. This can cuase the creation of large Data Objects. Arrayed fields are very cumbersome to manage also. By setting this custom token you can prevent these arrayed field form being included as properties in Data Objects and from many other Symphony tempaltes.
SYMPHONY_DECIMAL_FORMAT=string_format Allowsyou to define a format string that will be used when displaying the bound data. The string_format values determines the format string to be applied to the field..
SYMPHONY_SELWND_LENGTH=value When you assign a selection window to a field this token enables you to define the actual width of the resulting ComboBox control.

Decimal formatting considerations


By setting the token SYMPHONY_DECIMAL_FORMAT in the long description you can control how field data will be displayed. For example, if you have a D6 field an assinged the format dstring of ##0.0## you would always see a value in the field, even if it was null or zero. A format string of ###.### will display blank if the property is null or zero.

Examples


When you code genernate a style (using the Symphony_Style.tpl template) the generated XAML code defines the decimal field style based on the field attributes in the repository.

In this example we have defined a standard decimal field. The code generated style defines the synergyDecimalBox styling based on the attributes defined against the field.

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:symphonyConverters="clr-namespace:Symphony.Conductor.Converters;assembly=SymphonyConductor"
    xmlns:symphonyTriggers="clr-namespace:Symphony.Conductor.Triggers;assembly=SymphonyConductor"
    xmlns:symphonyUI="clr-namespace:Symphony.Crescendo.Presentation;assembly=SymphonyCrescendo"
    xmlns:symphonyControls="clr-namespace:Symphony.Conductor.Controls;assembly=SymphonyConductor"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Styles.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Converters.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="Custom_Cprnop_style" TargetType="{x:Type symphonyControls:FieldControl}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Focusable" Value="False"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type symphonyControls:FieldControl}">
                    <symphonyUI:SynergyDecimalBox
                        HorizontalAlignment="Left"
                        Name="ctlCustom_Cprnop"
                        Text="{Binding Path=Cprnop, Converter={StaticResource decimalConverter},
                                ConverterParameter=BLANKIFZERO, UpdateSourceTrigger=PropertyChanged,
                                ValidatesOnDataErrors=True}"
                                Validation.ErrorTemplate="{StaticResource validationTemplate}"
                        IsEnabled="{Binding Path=CprnopIsEnabled}"
                        IsReadOnly="{Binding Path=CprnopIsReadOnly}"
                        SynergyDecimalField="False"
                        MaxLength="1"
                        Width="16"
                        ToolTip="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors), Converter={StaticResource errorConveter}}">
                        <symphonyUI:SynergyDecimalBox.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=CprnopIsFocused}" Value="true">
                                        <Setter Property="FocusManager.FocusedElement"
                                                Value="{Binding ElementName=ctlCustom_Cprnop}"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </symphonyUI:SynergyDecimalBox.Style>
                    </symphonyUI:SynergyDecimalBox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>


To utilise the generated style in you UserControl or Window you simply reference the FieldControl class in the Symphony Framework and style it with the required field style.

<UserControl x:Class="MyProject.View.File_verify_DataView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:symphonyControls="clr-namespace:Symphony.Conductor.Controls;assembly=SymphonyConductor"
             mc:Ignorable="d"
             d:DesignHeight="600" d:DesignWidth="1100">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Styles.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Converters.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/MyProject;component/Resources/Custom_style.CodeGen.xaml"/>
                </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>


    <Grid>
        <symphonyControls:FieldControl
                DataContext="{Binding Path=MasterData}"
                Style="{StaticResource Custom_Cprnop_style}">
        </symphonyControls:FieldControl>
    </Grid>

</UserControl>

If the decimal field has a selection list or selection window assigned to it, then the style is created using a standard ComboBox control.

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:symphonyConverters="clr-namespace:Symphony.Conductor.Converters;assembly=SymphonyConductor"
    xmlns:symphonyTriggers="clr-namespace:Symphony.Conductor.Triggers;assembly=SymphonyConductor"
    xmlns:symphonyUI="clr-namespace:Symphony.Crescendo.Presentation;assembly=SymphonyCrescendo"
    xmlns:symphonyControls="clr-namespace:Symphony.Conductor.Controls;assembly=SymphonyConductor"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Styles.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Converters.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/SymphonyFileUtils;component/Resources/Custom_Content.CodeGen.xaml"/>
     </ResourceDictionary.MergedDictionaries>


    <Style x:Key="Custom_Cpryre_style" TargetType="{x:Type symphonyControls:FieldControl}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Focusable" Value="False"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type symphonyControls:FieldControl}">
                    <ComboBox
                        HorizontalAlignment="Left"
                        Name="ctlCustom_Cpryre"
                        ItemsSource="{Binding Source={StaticResource CPRYREitems}}"
                        DisplayMemberPath="Description"
                        SelectedValue="{Binding Path=Cpryre, Converter={StaticResource decimalConverter},
                        ValidatesOnDataErrors=True}"
                        Validation.ErrorTemplate="{StaticResource validationTemplate}"
                        SelectedValuePath="IndexValue"
                        IsEnabled="{Binding Path=CpryreIsEnabled}"
                        Width="100"
                        Margin="0,1,0,1"
                        ToolTip="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors), Converter={StaticResource errorConveter}}">
                        <ComboBox.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=CpryreIsFocused}" Value="true">
                                        <Setter Property="FocusManager.FocusedElement"
                                                Value="{Binding ElementName=ctlCustom_Cpryre}"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ComboBox.Style>
                    </ComboBox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>


The prompt is also defined within the style resource file.

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:symphonyConverters="clr-namespace:Symphony.Conductor.Converters;assembly=SymphonyConductor"
    xmlns:symphonyTriggers="clr-namespace:Symphony.Conductor.Triggers;assembly=SymphonyConductor"
    xmlns:symphonyUI="clr-namespace:Symphony.Crescendo.Presentation;assembly=SymphonyCrescendo"
    xmlns:symphonyControls="clr-namespace:Symphony.Conductor.Controls;assembly=SymphonyConductor"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Styles.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/SymphonyConductor;component/Resources/Converters.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/SymphonyFileUtils;component/Resources/Custom_Content.CodeGen.xaml"/>
     </ResourceDictionary.MergedDictionaries>


    <Style x:Key="Custom_Cprnop_prompt" TargetType="{x:Type Label}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Label}">
                    <Label
                        Content="Number of Laser Invoices"
                        IsEnabled="{Binding Path=CprnopIsEnabled}">
                    </Label>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>