ERPComboBox
A WPF ComboBox control that automatically displays all configured list values for a bound ERP field.
Namespace: powerGate.UI.Components
Assembly: powerGate.UI.dll
Inheritance Hierarchy
ComboBox
powerGate.UI.Components.ERPComboBox
Syntax
<ERPComboBox SelectedValue="{Binding *}"/>
Properties
All properties inherited from ComboBox are available, whereby only the assignment of SelectedValue
is required:
Property |
Usage |
Default value |
---|---|---|
SelectedValue |
Binding to an ERP field of Entity. |
|
ItemsSource |
All list-values which are configured for the ERP field bound in |
|
SelectedValuePath |
‘Erp’ (the underlying ERP value controls the display, and when selection changes, this ERP value is written back to the Entity field) |
|
DisplayMemberPath |
‘Display’ (the configured Display Text is shown for the selected value and dropdown items instead of the ERP values) |
|
VerticalAlignment |
‘Center’ |
|
Padding |
4 |
Remarks
The control displays all configured ERP values for a given field or, if configured, their corresponding display texts.
This is allowed by the default values of ItemsSource
and DisplayMemberPath
.
In combination with New-ERPObject -VaultEntity, this combobox aids displaying the respective ERP value for the mapped Vault Properties value.
SelectedValue
The control can only provide the above functionalities automatically when SelectedValue
is bound to an ERP field of an Entity returned by New-ERPObject -VaultEntity.
So the only requirement is a type mapping configuration between the ERP and Vault Entity type.
The customization development can also be continued without configured list-values. Once Possible Values are defined for the Item creation, these become visible in the combobox dropdown.
In contrast to a regular WPF ComboBox, a clear error tooltip displays to the Vault user when the ERP field has a value that is not available in its ItemsSource
.
The list-values themselves are displayed in sorted order by default, allowing them to quickly find and pick the ERP value of their choise.
If descending sorting is desired, the list-values can be ordered differently in the ERP Integration Settings dialog.
Warning
The ERPComboBox
does not work correctly if the parent Window uses the SizeToContent
attribute.
This is caused by a WPF bug that affects the Loaded
event which is required internally for the ERPComboBox
to work.
Examples
Using a ERPComboBox
requires an explicit XAML namespace declaration:
Assuming the StackPanel’s or ErpComboBox’s DataContext
provides an Entity with a UOM
property.
1 2 3 4 | <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:pg="clr-namespace:powerGate.UI.Components;assembly=powerGate.UI"> <pg:ERPComboBox SelectedValue="{Binding UOM}"/> </StackPanel> |
Displaying Configured List Values from another (custom) configuration section:
The ERPComboBox control in this example cannot automatically determine the configured list-values because:
the assigned DataContext is not a New-ERPObject
-VaultEntity
result (because Inventor)the Vault admin has only configured the language codes once for the ERP type ‘Description’, but does not want to configure an additional redundant ERP type mapping for ‘BasicDataText’
instead of a simple field a currently unsupported navigation property is bound
$window = [Windows.Markup.XamlReader]::Load( (New-Object System.Xml.XmlNodeReader @'
<Window Title="Inventor - Create ERP Item"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:pg="clr-namespace:powerGate.UI.Components;assembly=powerGate.UI">
<GroupBox Header="SAP Basic Data">
<StackPanel Orientation="Vertical">
...
<pg:ERPComboBox Name="LanguageComboBox"
SelectedValue="{Binding BasicData.BasicDataText.LanguageISO}" />
<TextBox Text="{Binding BasicData.BasicDataText.MatlDesc}" />
</StackPanel>
</GroupBox>
</Window>
'@) )
# programmatically set the ItemsSource to the configured list-value that are also used for Vault Items. Possible Language Codes are 'DE','IT','EN'
$vaultItem2SapDescription = $global:ERPSettings.GetTypeMapping('Item', 'material_srv.Description')
$languageCodeField = $vaultItem2SapDescription.FieldMappingsForCREATE | Where-Object { $_.ErpField -eq 'LanguageISO' }
$window.FindName('LanguageBasicTextComboBox').ItemsSource = $languageCodeField.ListValues # Possible Language Codes are 'DE','IT','EN'
$partNumber_iProperty = $document.PropertySets.Item('Design Tracking Properties')['Part Number']
$materialContext = New-ERPObject -EntityType 'material_srv.MaterialContext' -Properties @{ Material = $partNumber_iProperty.Value }
$materialContext.Description = @( (New-ERPObject -EntityType 'material_srv.Description') )
$materialContext.BasicData = New-ERPObject -EntityType 'material_srv.BasicData' -Properties @{ BasicDataText = @() }
$materialContext.BasicData.BasicDataText += New-ERPObject -EntityType 'material_srv.BasicDataText'
$window.DataContext = $materialContext
Disable other control in case of a Data Error:
When the Entity field holds invalid data, an automatically assigned DataErrorValidationRule ensures that the control shows these Validation.Errors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:pg="clr-namespace:powerGate.UI.Components;assembly=powerGate.UI"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <pg:ERPComboBox Name="Categories" SelectedValue="{Binding Category}" Grid.Row="0"/> <TextBox Text="{Binding Inventory, ValidatesOnDataErrors=True}" Grid.Row="1"> <!-- error validation may also supported for other fields --> <TextBox.Style> <Style TargetType="{x:Type TextBox}"> <Setter Property="IsEnabled" Value="False" /> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding ElementName=Categories, Path=(Validation.HasError)}" Value="False" /> ... </MultiDataTrigger.Conditions> <Setter Property="IsEnabled" Value="True" /> </MultiDataTrigger> </Style.Triggers> </Style> </TextBox.Style> </Button> </Grid> |