<local:ContextWindow
        x:Class="Elwig.Dialogs.DeliverySplittingDialog"
        AutomationProperties.AutomationId="DeliverySplittingDialog"
        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:local="clr-namespace:Elwig.Windows"
        xmlns:ctrl="clr-namespace:Elwig.Controls"
        ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
        WindowStartupLocation="CenterOwner"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="Lieferung abwerten oder aufteilen" Height="400" Width="600">
    <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="VerticalAlignment" Value="Bottom"/>
            <Setter Property="Width" Value="100"/>
            <Setter Property="Height" Value="25"/>
        </Style>
    </Window.Resources>
    <Grid>

        <RadioButton x:Name="DepreciateModeInput" GroupName="ModeInput" Content="Abwerten" Margin="15,10,10,10" IsChecked="True"
                     VerticalAlignment="Top" HorizontalAlignment="Left"
                     Checked="ModeInput_Changed"/>
        <RadioButton x:Name="MemberModeInput" GroupName="ModeInput" Content="Auf Mitglied übertragen" Margin="15,30,10,10"
                     VerticalAlignment="Top" HorizontalAlignment="Left"
                     Checked="ModeInput_Changed"/>
        <RadioButton x:Name="DeliveryModeInput" GroupName="ModeInput" Content="Zu anderer Lieferung hinzufügen" Margin="15,50,10,10"
                     VerticalAlignment="Top" HorizontalAlignment="Left"
                     Checked="ModeInput_Changed"/>

        <TextBox x:Name="MgNrInput" FontSize="14" Padding="2" Visibility="Hidden"
                 Width="48" Margin="220,10,0,0" Height="25" TextAlignment="Right"
                 TextChanged="MgNrInput_TextChanged"
                 VerticalAlignment="Top" HorizontalAlignment="Left"/>
        <ComboBox x:Name="MemberInput" FontSize="14" Visibility="Hidden"
                  Margin="273,10,40,10" IsEditable="True" Height="25"
                  ItemTemplate="{StaticResource MemberAdminNameTemplate}" TextSearch.TextPath="AdministrativeName"
                  SelectionChanged="MemberInput_SelectionChanged"
                  VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
        <Button x:Name="MemberReferenceButton" Height="25" Width="25" FontFamily="Segoe MDL2 Assets" Content="&#xEE35;" Padding="0"
                Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Right" ToolTip="Zu Mitglied springen" FontSize="14" Visibility="Hidden"
                Click="MemberReferenceButton_Click"/>

        <ComboBox x:Name="DeliveryInput" FontSize="14" Visibility="Hidden"
                  Margin="220,10,10,10" Height="25"
                  TextSearch.TextPath="LsNr"
                  SelectionChanged="DeliveryInput_SelectionChanged"
                  VerticalAlignment="Top" HorizontalAlignment="Stretch">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding LsNr}" Width="100"/>
                        <TextBlock Text="{Binding Weight, StringFormat='{}{0:N0} kg'}" Width="80" TextAlignment="Right" Margin="0,0,10,0"/>
                        <TextBlock Text="{Binding Member.AdministrativeName}"/>
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock x:Name="InfoBlock" Margin="230,45,10,10" FontSize="14" TextAlignment="Right"
                   VerticalAlignment="Top" HorizontalAlignment="Stretch"
                   Text="Insgesamt 0 kg / 0 kg ausgewählt."/>

        <ListBox x:Name="DeliveryPartList" Margin="10,75,10,40" ItemsSource="{Binding DeliveryParts, Mode=TwoWay}">
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Focusable" Value="False"/>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Part.DPNr}" Width="20" TextAlignment="Right"
                                   VerticalAlignment="Center"  Margin="0,0,5,0" FontSize="14"/>
                        <TextBlock Text="{Binding Part.SortId}" Width="40" TextAlignment="Center"
                                   VerticalAlignment="Center" Margin="0,0,0,0" FontSize="14"/>
                        <TextBlock Text="{Binding Part.Kmw, StringFormat='{}{0:N1}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"
                                   VerticalAlignment="Center"/>
                        <TextBlock Text="{Binding Part.QualId}" Width="30"
                                   VerticalAlignment="Center"/>
                        <TextBlock Text="{Binding Part.Weight, StringFormat='{}{0:N0} kg'}" Width="70" TextAlignment="Right"
                                   VerticalAlignment="Center" Margin="0,0,10,0" FontSize="14"/>
                        <TextBlock Text="{Binding Part.Attribute.Name}" Width="60"
                                   VerticalAlignment="Center"/>
                        <TextBlock Text="{Binding Part.Cultivation.Name}" Width="50"
                                   VerticalAlignment="Center"/>
                        <CheckBox IsChecked="{Binding SplitCompletely, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Content="Vollständig" Tag="{Binding Part.DPNr}"
                                  VerticalAlignment="Center" Margin="20,0,5,0"
                                  Checked="SplitCompletelyInput_Changed" Unchecked="SplitCompletelyInput_Changed"/>
                        <ctrl:UnitTextBox Text="{Binding SplitWeightString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Unit="kg" Width="70" Height="25" IsEnabled="{Binding SplitWeightEnabled}" Tag="{Binding Part.DPNr}"
                                          VerticalAlignment="Center" Margin="5,0,5,0" FontSize="14" Padding="2" Background="White"
                                          TextChanged="SplitWeightInput_TextChanged"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" IsEnabled="False"
                Click="ConfirmButton_Click"/>
        <Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" IsCancel="True"/>
    </Grid>
</local:ContextWindow>
