<local:AdministrationWindow
        x:Class="Elwig.Windows.BaseDataWindow"
        AutomationProperties.AutomationId="BaseDataWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Elwig.Windows"
        xmlns:ctrl="clr-namespace:Elwig.Controls"
        mc:Ignorable="d"
        Title="Stammdaten - Elwig" Height="520" MinHeight="400" Width="860" MinWidth="810"
        Loaded="Window_Loaded">
    <Window.Resources>
        <Style TargetType="Label">
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="Padding" Value="2,4,2,4"/>
            <Setter Property="Height" Value="25"/>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
        </Style>
        <Style TargetType="ctrl:UnitTextBox">
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="Height" Value="25"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
        </Style>
        <Style TargetType="Button">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="9,3"/>
            <Setter Property="Height" Value="27"/>
        </Style>
    </Window.Resources>
    <Grid>
        <TabControl Margin="10,10,10,42">
            <TabItem Header="Mandant">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="130"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="90"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Label Content="Vollständiger Name:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,10,0,10"/>
                    <TextBox x:Name="ClientNameFull" IsEnabled="False"
                             VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,10,10,10"/>

                    <Label Content="Name:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,40,0,10"/>
                    <TextBox x:Name="ClientNameInput"
                             TextChanged="ClientNames_TextChanged"
                             VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,40,10,10"/>

                    <Label Content="Namenszusatz:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,70,0,10"/>
                    <TextBox x:Name="ClientNameSuffixInput"
                             TextChanged="ClientNames_TextChanged"
                             VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,70,10,10"/>

                    <Label Content="Gesellschaftsform:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,100,0,10"/>
                    <TextBox x:Name="ClientNameTypeInput"
                             TextChanged="ClientNames_TextChanged"
                             VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Margin="0,100,10,10"/>

                    <Label Content="Kürzel/Kurzform:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,130,0,10"/>
                    <TextBox x:Name="ClientNameTokenInput"
                             TextChanged="TextBox_TextChanged"
                             VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="1" Margin="0,130,10,10" Width="70"/>
                    <TextBox x:Name="ClientNameShortInput"
                                TextChanged="TextBox_TextChanged"
                             VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Margin="75,130,10,10"/>

                    <Label Content="Adresse:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,160,0,10"/>
                    <TextBox x:Name="ClientAddressInput"
                             TextChanged="TextBox_TextChanged"
                             VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.Column="1" Margin="0,160,10,10"/>

                    <Label Content="PLZ/Ort:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Margin="10,190,0,10"/>
                    <TextBox x:Name="ClientPlzInput"
                             Margin="0,190,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
                             TextChanged="PlzInput_TextChanged" LostFocus="PlzInput_LostFocus"/>
                    <TextBox x:Name="ClientOrtInput" Margin="47,190,10,0" Grid.Column="1"
                             TextChanged="TextBox_TextChanged"/>

                    <Label Content="IBAN:" Margin="10,220,0,0" Grid.Column="0"/>
                    <TextBox x:Name="ClientIbanInput" Margin="0,220,10,0" Grid.Column="1"
                         TextChanged="IbanInput_TextChanged" LostFocus="IbanInput_LostFocus"/>

                    <Label Content="BIC:" Margin="10,250,0,0" Grid.Column="0"/>
                    <TextBox x:Name="ClientBicInput" Margin="0,250,10,0" Grid.Column="1"
                         TextChanged="BicInput_TextChanged" LostFocus="BicInput_LostFocus"/>

                    <Label Content="UID:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,100,0,10"/>
                    <TextBox x:Name="ClientUstIdNrInput"
                             VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="3" Margin="0,100,10,10" Width="96"
                             TextChanged="UstIdNrInput_TextChanged" LostFocus="UstIdNrInput_LostFocus"/>

                    <Label Content="Betriebs-Nr.:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,130,0,10"/>
                    <TextBox x:Name="ClientLfbisNrInput"
                             VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="3" Margin="0,130,10,10" Width="64"
                             TextChanged="LfbisNrInput_TextChanged" LostFocus="LfbisNrInput_LostFocus"/>

                    <Label Content="Bio-Kontrollstelle:"
                           VerticalAlignment="Top" HorizontalAlignment="Right" Grid.Column="3" Margin="10,130,110,10"/>
                    <TextBox x:Name="ClientOrganicAuthorityInput"
                             VerticalAlignment="Top" HorizontalAlignment="Right" Grid.Column="3" Margin="10,130,10,10" Width="90"
                             TextChanged="OrganicAuthorityCodeInput_TextChanged" LostFocus="OrganicAuthorityCodeInput_LostFocus"/>

                    <Label Content="Telefon-Nr.:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,160,0,10"/>
                    <TextBox x:Name="ClientPhoneNrInput" Margin="0,160,10,10" Grid.Column="3"
                             TextChanged="PhoneNrInput_TextChanged" LostFocus="PhoneNrInput_LostFocus"/>

                    <Label Content="Fax-Nr.:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,190,0,10"/>
                    <TextBox x:Name="ClientFaxNrInput" Margin="0,190,10,10" Grid.Column="3"
                             TextChanged="PhoneNrInput_TextChanged" LostFocus="PhoneNrInput_LostFocus"/>

                    <Label Content="E-Mail-Adr.:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,220,0,10"/>
                    <TextBox x:Name="ClientEmailAddressInput" Margin="0,220,10,0" Grid.Column="3"
                             TextChanged="EmailAddressInput_TextChanged" LostFocus="EmailAddressInput_LostFocus"/>

                    <Label Content="Website:"
                           VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="2" Margin="10,250,0,10"/>
                    <TextBox x:Name="ClientWebsiteInput" Margin="0,250,10,0" Grid.Column="3"
                             TextChanged="TextBox_TextChanged"/>
                </Grid>
            </TabItem>
            <TabItem Header="Zweigstellen">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="260"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <ListBox x:Name="BranchList" Margin="10,10,35,10"
                             SelectionChanged="BranchList_SelectionChanged" Grid.Column="0">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding ZwstId}" Width="20"/>
                                    <TextBlock Text="{Binding Name}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <Button x:Name="BranchAddButton" Content="&#xF8AA;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="BranchAddButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,30" Grid.Column="0"/>
                    <Button x:Name="BranchDeleteButton" Content="&#xF8AB;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="BranchDeleteButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,30,5,0" Grid.Column="0"/>

                    <Grid Grid.Column="1" Margin="0,10,0,10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Content="Identifikator:" Margin="10,10,0,10"/>
                        <TextBox x:Name="BranchIdInput" Grid.Column="1" Margin="0,10,10,10" Width="50" HorizontalAlignment="Left"
                                 TextChanged="Branch_Changed"/>

                        <Label Content="Name:" Margin="10,40,0,10"/>
                        <TextBox x:Name="BranchNameInput" Grid.Column="1" Margin="0,40,10,10" Width="150" HorizontalAlignment="Left"
                                 TextChanged="Branch_Changed"/>

                        <Label Content="PLZ/Ort:" Margin="10,70,0,10"/>
                        <TextBox x:Name="BranchPlzInput" Margin="0,70,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
                                 TextChanged="BranchPlzInput_TextChanged" LostFocus="PlzInput_LostFocus" Tag="PLZ"/>
                        <ComboBox x:Name="BranchOrtInput" ItemTemplate="{StaticResource PostalDestTemplate}" TextSearch.TextPath="Ort.Name"
                                  Margin="47,70,10,0" Grid.Column="1" Grid.ColumnSpan="3" Width="253" HorizontalAlignment="Left"
                                  SelectionChanged="Branch_Changed"/>

                        <Label Content="Adresse:" Margin="10,100,0,10"/>
                        <TextBox x:Name="BranchAddressInput" Grid.Column="1" Margin="0,100,10,10" Width="300" HorizontalAlignment="Left"
                                 TextChanged="Branch_Changed"/>

                        <Label Content="Tel.-Nr. (Festnetz):" Margin="10,130,0,10"/>
                        <TextBox x:Name="BranchPhoneNrInput" Grid.Column="1" Margin="0,130,10,10" Width="200" HorizontalAlignment="Left"
                                 TextChanged="BranchPhoneNr_TextChanged"/>

                        <Label Content="Fax-Nr.:" Margin="10,160,0,10"/>
                        <TextBox x:Name="BranchFaxNrInput" Grid.Column="1" Margin="0,160,10,10" Width="200" HorizontalAlignment="Left"
                                 TextChanged="BranchPhoneNr_TextChanged"/>

                        <Label Content="Tel.-Nr. (mobil):" Margin="10,190,0,10"/>
                        <TextBox x:Name="BranchMobileNrInput" Grid.Column="1" Margin="0,190,10,10" Width="200" HorizontalAlignment="Left"
                                 TextChanged="BranchPhoneNr_TextChanged"/>
                    </Grid>
                </Grid>
            </TabItem>
            <TabItem Header="Sortenattribute">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="280"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <ListBox x:Name="WineAttributeList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,35,10"
                             SelectionChanged="WineAttributeList_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding AttrId}" Width="30"/>
                                    <TextBlock Text="{Binding Name}" Width="80"/>
                                    <TextBlock Text="{Binding MaxKgPerHa, StringFormat='{}{0:N0} kg'}" Width="60" TextAlignment="Right" Margin="0,0,5,0"/>
                                    <CheckBox IsChecked="{Binding IsActive}" IsEnabled="False" Margin="10,0,10,0"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <Button x:Name="WineAttributeAddButton" Content="&#xF8AA;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="WineAttributeAddButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,30"/>
                    <Button x:Name="WineAttributeDeleteButton" Content="&#xF8AB;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="WineAttributeDeleteButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,30,5,0"/>

                    <Grid Grid.Column="1" Margin="0,10,0,10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Content="Identifikator:" Margin="10,10,0,10"/>
                        <TextBox x:Name="WineAttributeIdInput" Grid.Column="1" Margin="0,10,10,10" Width="50" HorizontalAlignment="Left"
                                 TextChanged="WineAttributeIdInput_TextChanged"/>

                        <Label Content="Name:" Margin="10,40,0,10"/>
                        <TextBox x:Name="WineAttributeNameInput" Grid.Column="1" Margin="0,40,10,10" Width="150" HorizontalAlignment="Left"
                                 TextChanged="WineAttribute_Changed"/>

                        <CheckBox x:Name="WineAttributeActiveInput" Content="In Übernahme-Fenster anzeigen"
                                  Grid.Column="1" Margin="0,74,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
                                  Checked="WineAttribute_Changed" Unchecked="WineAttribute_Changed"/>

                        <GroupBox Header="Auszahlung" Grid.ColumnSpan="2" Margin="10,100,10,10">
                            <Grid>
                                <Label Content="Max. Ertrag:" Margin="10,10,0,10"/>
                                <ctrl:UnitTextBox x:Name="WineAttributeMaxKgPerHaInput" Unit="kg/ha" TextChanged="WineAttributeMaxKgPerHaInput_TextChanged"
                                                  Grid.Column="1" Width="80" Margin="84,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                                <Label Content="(wenn abweichend vom max. Ertrag der Saison)" Margin="170,10,0,10"/>

                                <CheckBox x:Name="WineAttributeStrictInput" Content="Strikte Trennung zu Flächenbindung ohne Attribut"
                                          Margin="10,50,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
                                          Checked="WineAttributeStrictInput_Changed" Unchecked="WineAttributeStrictInput_Changed"/>

                                <Label x:Name="WineAttributeFillLowerLabel" Content="Wenn möglich, Flächenbindung ohne Attribut..." Margin="10,75,10,10"/>
                                <ComboBox x:Name="WineAttributeFillLowerInput" Width="300"
                                          Margin="10,100,10,10" HorizontalAlignment="Left"
                                          SelectionChanged="WineAttribute_Changed">
                                    <ComboBoxItem>...nicht auffüllen</ComboBoxItem>
                                    <ComboBoxItem>...bis Lieferpflicht auffüllen</ComboBoxItem>
                                    <ComboBoxItem>...bis Lieferrecht auffüllen</ComboBoxItem>
                                </ComboBox>
                            </Grid>
                        </GroupBox>
                    </Grid>
                </Grid>
            </TabItem>
            <TabItem Header="Bewirtschaftungsarten">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="260"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <ListBox x:Name="WineCultivationList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,35,10"
                             SelectionChanged="WineCultivationList_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding CultId}" Width="30"/>
                                    <TextBlock Text="{Binding Name}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <Button x:Name="WineCultivationAddButton" Content="&#xF8AA;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="WineCultivationAddButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,30"/>
                    <Button x:Name="WineCultivationDeleteButton" Content="&#xF8AB;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="WineCultivationDeleteButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,30,5,0"/>

                    <Grid Grid.Column="1" Margin="0,10,0,10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Content="Identifikator:" Margin="10,10,0,10"/>
                        <TextBox x:Name="WineCultivationIdInput" Grid.Column="1" Margin="0,10,10,10" Width="50" HorizontalAlignment="Left"
                                 TextChanged="WineCultivationIdInput_TextChanged"/>

                        <Label Content="Name:" Margin="10,40,0,10"/>
                        <TextBox x:Name="WineCultivationNameInput" Grid.Column="1" Margin="0,40,10,10" Width="150" HorizontalAlignment="Left"
                                 TextChanged="WineCultivation_Changed"/>

                        <Label Content="Beschreibung:" Margin="10,70,0,10"/>
                        <TextBox x:Name="WineCultivationDescriptionInput" Grid.Column="1" Margin="0,70,10,10"
                                 TextChanged="WineCultivation_Changed"/>
                    </Grid>
                </Grid>
            </TabItem>

            <TabItem Header="Flächenbindungsverträge" x:Name="AreaCommitmentTypes">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="260"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <ListBox x:Name="AreaCommitmentTypeList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,35,10"
                             SelectionChanged="AreaCommitmentTypeList_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding SortId}" Width="30" Foreground="{Binding WineVar.Color}"/>
                                    <TextBlock Text="{Binding WineAttr.Name}" Width="70"/>
                                    <TextBlock Text="{Binding Discriminator}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <Button x:Name="AreaCommitmentTypeAddButton" Content="&#xF8AA;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="AreaCommitmentTypeAddButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,30"/>
                    <Button x:Name="AreaCommitmentTypeDeleteButton" Content="&#xF8AB;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                            Click="AreaCommitmentTypeDeleteButton_Click"
                            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,30,5,0"/>

                    <Grid Grid.Column="1" Margin="0,10,0,10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="80"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Content="Identifikator:" Margin="10,10,0,10"/>
                        <TextBox x:Name="AreaCommitmentTypeIdInput" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,10,10,10" Width="50" HorizontalAlignment="Left" IsEnabled="False"/>

                        <Label Content="Sorte:" Margin="10,40,0,10"/>
                        <ComboBox x:Name="AreaCommitmentTypeWineVariantInput" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,40,10,10" Width="250" HorizontalAlignment="Left"
                                  TextSearch.TextPath="Name"
                                  SelectionChanged="AreaCommitmentType_Changed">
                            <ComboBox.ItemTemplateSelector>
                                <ctrl:WineVarietyTemplateSelector/>
                            </ComboBox.ItemTemplateSelector>
                        </ComboBox>

                        <Label Content="Attribut:" Margin="10,70,0,10"/>
                        <ComboBox x:Name="AreaCommitmentTypeWineAttributeInput" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,70,10,10" Width="250" HorizontalAlignment="Left"
                                  SelectionChanged="AreaCommitmentType_Changed"/>

                        <Label Content="Lieferpflicht:" Margin="10,100,0,10" Grid.ColumnSpan="2"/>
                        <ctrl:UnitTextBox x:Name="AreaCommitmentTypeMinKgPerHaInput" Unit="kg/ha" Grid.Column="2" Margin="0,100,10,10" Width="80" HorizontalAlignment="Left" VerticalAlignment="Top"
                                          TextChanged="AreaCommitmentTypeMinKgPerHa_TextChanged"/>

                        <Label Content="Strafe (pro unterl. kg):" Margin="10,130,0,10" Grid.ColumnSpan="2"/>
                        <ctrl:UnitTextBox x:Name="AreaCommitmentTypePenaltyPerKgInput" Unit="€/kg" Grid.Column="2" Margin="0,130,10,10" Width="80"
                                          HorizontalAlignment="Left" VerticalAlignment="Top"
                                          TextChanged="AreaCommitmentTypePenaltyPerKgInput_TextChanged"/>

                        <Label Content="Strafe (bei Unterlieferung):" Margin="10,160,0,10" Grid.ColumnSpan="2"/>
                        <ctrl:UnitTextBox x:Name="AreaCommitmentTypePenaltyInput" Unit="€" Grid.Column="2" Margin="0,160,10,10" Width="68"
                                          HorizontalAlignment="Left" VerticalAlignment="Top"
                                          TextChanged="AreaCommitmentTypePenaltyInput_TextChanged"/>

                        <Label Content="Strafe (bei Nicht-Lieferung):" Margin="10,190,0,10" Grid.ColumnSpan="2"/>
                        <ctrl:UnitTextBox x:Name="AreaCommitmentTypePenaltyNoneInput" Unit="€" Grid.Column="2" Margin="0,190,10,10" Width="68"
                                          HorizontalAlignment="Left" VerticalAlignment="Top"
                                          TextChanged="AreaCommitmentTypePenaltyInput_TextChanged"/>
                    </Grid>
                </Grid>
            </TabItem>

            <TabItem Header="Saisons" x:Name="Seasons">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="180"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="180"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <ListBox x:Name="SeasonList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,40" Grid.RowSpan="2"
                             SelectionChanged="SeasonList_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Year}" Width="40"/>
                                    <TextBlock Text="{Binding Currency.Name}" Width="60"/>
                                    <TextBlock Text="{Binding Precision}" Width="10"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <Button x:Name="SeasonAddButton" Content="Neu anlegen..." FontSize="12" Height="25" Grid.Row="2"
                            VerticalAlignment="Bottom" Margin="10,10,40,10" Padding="0,0,0,0"
                            Click="SeasonAddButton_Click"/>
                    <Button x:Name="SeasonRemoveButton" Content="&#xE74D;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Height="25" Width="25"
                            VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="10,10,10,10" Padding="0.5,0,0,0"
                            Click="SeasonRemoveButton_Click"/>

                    <Grid Grid.Column="1" Margin="0,10,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="130"/>
                            <ColumnDefinition Width="120"/>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Content="Maximaler Ertrag:" Margin="10,10,0,10"/>
                        <ctrl:UnitTextBox x:Name="SeasonMaxKgPerHaInput" Unit="kg/ha" TextChanged="SeasonMinMaxKgInput_TextChanged"
                                          Grid.Column="1" Width="80" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                        <Label Content="MwSt. (buchführend):" Margin="10,40,0,10"/>
                        <ctrl:UnitTextBox x:Name="SeasonVatNormalInput" Unit="%" TextChanged="SeasonVatInput_TextChanged"
                                          Grid.Column="1" Width="48" Margin="0,40,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                        <Label Content="MwSt. (pauschaliert):" Margin="10,70,0,10"/>
                        <ctrl:UnitTextBox x:Name="SeasonVatFlatrateInput" Unit="%" TextChanged="SeasonVatInput_TextChanged"
                                          Grid.Column="1" Width="48" Margin="0,70,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                        <Label Content="Übernahme-Beginn:" Margin="10,100,0,10"/>
                        <TextBox x:Name="SeasonStartInput" Grid.Column="1" Margin="0,100,10,10" Width="78" IsEnabled="False"
                                 HorizontalAlignment="Left"/>

                        <Label Content="Übernahme-Ende:" Margin="10,130,0,10"/>
                        <TextBox x:Name="SeasonEndInput" Grid.Column="1" Margin="0,130,10,10" Width="78" IsEnabled="False"
                                 HorizontalAlignment="Left"/>

                        <Label Content="Lieferpflicht/-recht:" Margin="10,10,0,10" Grid.Column="2"/>
                        <ctrl:UnitTextBox x:Name="SeasonMinKgPerBsInput" Unit="kg/GA" TextChanged="SeasonMinMaxKgInput_TextChanged"
                                          Grid.Column="3" Width="80" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                        <ctrl:UnitTextBox x:Name="SeasonMaxKgPerBsInput" Unit="kg/GA" TextChanged="SeasonMinMaxKgInput_TextChanged"
                                          Grid.Column="3" Width="80" Margin="85,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                        <Label Content="GA-Wert (Nachz.):" Margin="10,40,0,10" Grid.Column="2"/>
                        <ctrl:UnitTextBox x:Name="SeasonBsValueInput" Unit="€/GA" TextChanged="SeasonPenaltyInput_TextChanged"
                                          Grid.Column="3" Width="85" Margin="0,40,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                        <GroupBox Header="Strafen bei Unterlieferung lt. GA" Grid.Column="2" Grid.ColumnSpan="2" Margin="0,70,10,0">
                            <Grid>
                                <ctrl:UnitTextBox x:Name="SeasonPenaltyPerKgInput" Unit="€/kg" TextChanged="SeasonPenaltyPerKgInput_TextChanged"
                                                  Width="80" Margin="65,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                                <ctrl:UnitTextBox x:Name="SeasonPenaltyInput" Unit="€" TextChanged="SeasonPenaltyInput_TextChanged"
                                                  Width="68" Margin="150,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                                <ctrl:UnitTextBox x:Name="SeasonPenaltyPerBsInput" Unit="€/GA" TextChanged="SeasonPenaltyPerBsInput_TextChanged"
                                                  Width="100" Margin="222,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                                <Label Content="Zzgl. bei Nicht-Lieferung:" Margin="10,40,0,10"/>
                                <ctrl:UnitTextBox x:Name="SeasonPenaltyNoneInput" Unit="€" TextChanged="SeasonPenaltyInput_TextChanged"
                                                  Width="68" Margin="150,40,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                                <ctrl:UnitTextBox x:Name="SeasonPenaltyPerBsNoneInput" Unit="€/GA" TextChanged="SeasonPenaltyPerBsInput_TextChanged"
                                                  Width="100" Margin="222,40,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                            </Grid>
                        </GroupBox>
                    </Grid>

                    <GroupBox Grid.Column="1" Grid.Row="1" Header="Zu-/Abschläge" Margin="0,0,10,10" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="400"/>
                                <ColumnDefinition Width="70"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <ListBox x:Name="SeasonModifierList" SelectionChanged="SeasonModifierList_SelectionChanged"
                                     HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="350" Margin="10,10,10,10">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding ModId}" Width="30"/>
                                            <TextBlock Text="{Binding Name}" Width="200" Margin="0,0,10,0"/>
                                            <TextBlock Text="{Binding ValueStr}"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                            <Button x:Name="SeasonModifierUpButton" Content="&#xE96D;" FontFamily="Segoe MDL2 Assets" FontSize="10" Padding="0,0,0,0" IsEnabled="False"
                                    Click="SeasonModifierUpButton_Click"
                                    VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,0,0,90"/>
                            <Button x:Name="SeasonModifierDownButton" Content="&#xE96E;" FontFamily="Segoe MDL2 Assets" FontSize="10" Padding="0,2,0,0" IsEnabled="False"
                                    Click="SeasonModifierDownButton_Click"
                                    VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,0,0,30"/>
                            <Button x:Name="SeasonModifierAddButton" Content="&#xF8AA;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                                    Click="SeasonModifierAddButton_Click"
                                    VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,30,0,0"/>
                            <Button x:Name="SeasonModifierDeleteButton" Content="&#xF8AB;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False"
                                    Click="SeasonModifierDeleteButton_Click"
                                    VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Margin="365,90,0,0"/>

                            <Label Content="ID:" Grid.Column="1" Margin="10,10,10,10"/>
                            <TextBox x:Name="SeasonModifierIdInput" Grid.Column="2" Margin="0,10,10,10" Width="50" HorizontalAlignment="Left"
                                     TextChanged="SeasonModifierIdInput_TextChanged"/>

                            <Label Content="Name:" Grid.Column="1" Margin="10,40,10,10"/>
                            <TextBox x:Name="SeasonModifierNameInput" Grid.Column="2" Margin="0,40,10,10"
                                     TextChanged="SeasonModifier_Changed"/>

                            <Label Content="Relativ:" Grid.Column="1" Margin="10,70,10,10"/>
                            <ctrl:UnitTextBox x:Name="SeasonModifierRelInput" Unit="%" TextChanged="SeasonModifierRelInput_TextChanged"
                                             Grid.Column="2" Width="68" Margin="0,70,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                            <Label Content="Absolut:" Grid.Column="1" Margin="10,100,10,10"/>
                            <ctrl:UnitTextBox x:Name="SeasonModifierAbsInput" Unit="€/kg" TextChanged="SeasonModifierAbsInput_TextChanged"
                                             Grid.Column="2" Width="86" Margin="0,100,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                            <CheckBox x:Name="SeasonModifierActiveInput" Content="In Übernahme-Fenster anzeigen"
                                      Grid.Column="1" Grid.ColumnSpan="2" Margin="10,134,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
                                      Checked="SeasonModifier_Changed" Unchecked="SeasonModifier_Changed"/>

                            <CheckBox x:Name="SeasonModifierRedactedInput" Content="Wert auf Lieferschein verbergen"
                                      Grid.Column="1" Grid.ColumnSpan="2" Margin="10,154,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
                                      Checked="SeasonModifier_Changed" Unchecked="SeasonModifier_Changed"/>
                        </Grid>
                    </GroupBox>
                </Grid>
            </TabItem>
            <TabItem Header="Parameter">
                <StackPanel>
                    <GroupBox x:Name="ParameterAreaComGroup" Header="Berechnung Flächenbindungen (aktuelle Saison)" Margin="10,10,10,0" VerticalAlignment="Top">
                        <Grid>
                            <CheckBox x:Name="ParameterAllowAttrIntoLowerInput" Content="Erlauben Lieferungen auch auf (konfigurierte) &quot;schlechtere&quot; Flächenbindungen aufzuteilen"
                                      VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,10,10"
                                      Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
                            <CheckBox x:Name="ParameterAvoidUnderDeliveriesInput" Content="Unterlieferungen durch Abzug bei &quot;besseren&quot; Flächenbindungen vermeiden"
                                      VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,30,10,10"
                                      Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
                            <CheckBox x:Name="ParameterHonorGebundenInput" Margin="10,50,10,10" VerticalAlignment="Top"
                                      Checked="CheckBox_Changed" Unchecked="CheckBox_Changed">
                                <TextBlock>Bei Lieferungen das Feld <Italic>Gebunden</Italic> berücksichtigen</TextBlock>
                            </CheckBox>
                        </Grid>
                    </GroupBox>

                    <GroupBox Header="Daten-Export" Margin="10,10,10,10">
                        <Grid>
                            <Label Content="Version EBICS-Überweisung:" Margin="10,10,10,10"/>
                            <ComboBox x:Name="ParameterExportEbicsVersion" Margin="180,10,10,10" Width="50"
                                      HorizontalAlignment="Left">
                                <ComboBoxItem>3</ComboBoxItem>
                                <ComboBoxItem>4</ComboBoxItem>
                                <ComboBoxItem>5</ComboBoxItem>
                                <ComboBoxItem>6</ComboBoxItem>
                                <ComboBoxItem>7</ComboBoxItem>
                                <ComboBoxItem>8</ComboBoxItem>
                                <ComboBoxItem IsSelected="True">9</ComboBoxItem>
                                <ComboBoxItem>10</ComboBoxItem>
                                <ComboBoxItem>11</ComboBoxItem>
                            </ComboBox>

                            <Label Content="Adressen EBICS-Überweisung:" Margin="10,40,10,10"/>
                            <ComboBox x:Name="ParameterExportEbicsAddress" Margin="180,40,10,10" Width="150"
                                      HorizontalAlignment="Left">
                                <ComboBoxItem>Nicht anführen</ComboBoxItem>
                                <ComboBoxItem>Adresszeilen</ComboBoxItem>
                                <ComboBoxItem IsSelected="True">Vollwertig</ComboBoxItem>
                            </ComboBox>
                        </Grid>
                    </GroupBox>
                </StackPanel>
            </TabItem>
            <TabItem Header="Textelemente">
                <ScrollViewer VerticalScrollBarVisibility="Visible">
                    <StackPanel>
                        <GroupBox Header="Lieferschein" Margin="10,10,10,10" Height="180">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="370"/>
                                </Grid.ColumnDefinitions>

                                <TextBox x:Name="TextElementDeliveryNote" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible"
                                         HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" Height="Auto"
                                         TextChanged="TextBox_TextChanged"/>
                                <GroupBox Grid.Column="1" Header="Tabelle zur Gesamtlieferung" Margin="10,10,10,10" VerticalAlignment="Center">
                                    <StackPanel Margin="5,5,0,5">
                                        <RadioButton GroupName="ModeDeliveryNote" x:Name="ModeDeliveryNoteNone" Content="Verbergen"
                                                     Checked="RadioButton_Changed" Unchecked="RadioButton_Changed"/>
                                        <RadioButton GroupName="ModeDeliveryNote" x:Name="ModeDeliveryNoteGaOnly" Content="Nur Gesamtlieferung lt. Geschäftsanteilen anzeigen"
                                                     Checked="RadioButton_Changed" Unchecked="RadioButton_Changed"/>
                                        <RadioButton GroupName="ModeDeliveryNote" x:Name="ModeDeliveryNoteShort" Content="Nur Gesamtlieferung und Flächenbindungen von auf dem&#xA;Lieferschein angeführten Sorten anzeigen"
                                                     Checked="RadioButton_Changed" Unchecked="RadioButton_Changed"/>
                                        <RadioButton GroupName="ModeDeliveryNote" x:Name="ModeDeliveryNoteFull" Content="Vollständig anzeigen"
                                                     Checked="RadioButton_Changed" Unchecked="RadioButton_Changed"/>
                                    </StackPanel>
                                </GroupBox>
                            </Grid>
                        </GroupBox>
                        <GroupBox Header="Anlieferungsbestätigung" Margin="10,10,10,10" Height="250">
                            <Grid>
                                <TextBox x:Name="TextElementDeliveryConfirmation" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"
                                         HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" Height="Auto"
                                         TextChanged="TextBox_TextChanged"/>
                            </Grid>
                        </GroupBox>
                        <GroupBox Header="Traubengutschrift" Margin="10,10,10,10" Height="250">
                            <Grid>
                                <TextBox x:Name="TextElementCreditNote" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"
                                         HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10" Height="Auto"
                                         TextChanged="TextBox_TextChanged"/>
                            </Grid>
                        </GroupBox>
                    </StackPanel>
                </ScrollViewer>
            </TabItem>
        </TabControl>

        <Button x:Name="OriginButton" Content="Herkunftshierarchie"
                HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10,10,10,10" Width="150"
                Click="OriginButton_Click"/>

        <Button x:Name="EditButton" Content="Bearbeiten"
                HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,10" Width="120"
                Click="EditButton_Click">
            <Button.ToolTip>
                <TextBlock FontWeight="Bold">Strg+B</TextBlock>
            </Button.ToolTip>
        </Button>
        <Button x:Name="SaveButton" Content="Speichern" IsEnabled="False"
                HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,250,10" Width="120"
                Click="SaveButton_Click">
            <Button.ToolTip>
                <TextBlock FontWeight="Bold">Strg+S</TextBlock>
            </Button.ToolTip>
        </Button>
        <Button x:Name="ResetButton" Content="Zurücksetzen" IsEnabled="False" Visibility="Hidden"
                HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,10" Width="120"
                Click="ResetButton_Click">
            <Button.ToolTip>
                <TextBlock FontWeight="Bold">Strg+Z</TextBlock>
            </Button.ToolTip>
        </Button>
        <Button x:Name="CancelButton" Content="Abbrechen" IsEnabled="False" IsCancel="True"
                HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="250,0,0,10" Width="120"
                Click="CancelButton_Click">
            <Button.ToolTip>
                <TextBlock FontWeight="Bold">Esc</TextBlock>
            </Button.ToolTip>
        </Button>
    </Grid>
</local:AdministrationWindow>
