Uniconta Add XAML / WPF VariantEditor in code

Date: 2021-02-04
<Grid Margin="0 10">
	<Grid.ColumnDefinitions>
		<ColumnDefinition Width="50*" />
		<ColumnDefinition Width="50*" />
	</Grid.ColumnDefinitions>
	<Label Grid.Column="0" Height="25" HorizontalAlignment="Left" VerticalAlignment="Center">
		<l:Translate Key="Variant" />
	</Label>
	<StackPanel Name="PnlVariant" Grid.Column="1" />
</Grid>
PnlVariant.Children.Clear();
var leVariant = new VariantEditor();
var control = new VariantControl();
control.API = api;
control.DataContext = ViewModel.ProductionOrder;
leVariant.Context = control;
leVariant.DataContext = ViewModel.ProductionOrder;
leVariant.SetBinding(BaseEdit.EditValueProperty, "Variant");
PnlVariant.Children.Add(leVariant);
<!-- The original version with DataContext switching issues -->
<controls:VariantEditor Grid.Column="1" x:Name="leVariant" DataContext="{Binding Path=ProductionOrder}" EditValue="{Binding Variant,Mode=TwoWay}"  />
45840cookie-checkUniconta Add XAML / WPF VariantEditor in code