<Window
    x:Class="BPASmartClient.DosingSystem.View.NewRecipeView"
    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:BPASmartClient.DosingSystem.View"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
    Title="NewRecipeView"
    Width="550"
    Height="450"
    AllowsTransparency="True"
    Background="{x:Null}"
    Topmost="True"
    WindowStartupLocation="CenterScreen"
    WindowStyle="None"
    mc:Ignorable="d">

    <Window.DataContext>
        <vm:NewRecipeViewModel />
    </Window.DataContext>

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
                <ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />

                <ResourceDictionary>
                    <!--#region ListBox样式-->
                    <Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
                        <Setter Property="OverridesDefaultStyle" Value="True" />
                        <Setter Property="SnapsToDevicePixels" Value="True" />
                        <Setter Property="BorderBrush" Value="{x:Null}" />
                        <Setter Property="Foreground" Value="White" />
                        <Setter Property="FontSize" Value="20" />
                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                        <Setter Property="VerticalContentAlignment" Value="Center" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Border x:Name="border" CornerRadius="8">
                                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                    <!--#endregion-->
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Border Name="br" BorderThickness="1">
        <Border.Background>
            <ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" />
        </Border.Background>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="5" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <!--<Button
                Name="btClose"
                Margin="0,0,5,0"
                Padding="10,5"
                HorizontalAlignment="Right"
                VerticalAlignment="Center"
                Background="Transparent"
                BorderThickness="0"
                Content="X"
                FontSize="18"
                Foreground="White" />

            <Border BorderBrush="#88DDDDDD" BorderThickness="0,0,0,1" />-->

            <Grid Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <TextBlock
                    Margin="10,0,0,0"
                    Background="Transparent"
                    FontSize="20"
                    Foreground="#FF2AB2E7"
                    Text="请输入配方名称：" />

                <TextBlock
                    Margin="0,0,10,0"
                    HorizontalAlignment="Right"
                    Background="Transparent"
                    FontSize="16"
                    Foreground="Red"
                    Text="{Binding ErrorInfo}" />

                <StackPanel
                    Grid.Row="1"
                    Margin="10,0,0,0"
                    Orientation="Horizontal">

                    <TextBox
                        Grid.Column="1"
                        Width="200"
                        Height="30"
                        Margin="0,0,7,0"
                        FontSize="16"
                        Text="{Binding RecipeName}" />

                    <Button
                        Width="148"
                        Height="30"
                        Margin="0,0,7,0"
                        Command="{Binding AddCommand}"
                        Content="添加原料" />

                    <Button
                        Width="80"
                        Height="30"
                        Command="{Binding SaveCommand}"
                        Content="确认" />

                    <Button
                        Name="btClose"
                        Width="80"
                        Height="30"
                        Margin="7,0,0,0"
                        Content="取消" />

                </StackPanel>

                <ScrollViewer Grid.Row="2" Margin="5">
                    <ItemsControl ItemsSource="{Binding RawMaterials}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <RadioButton GroupName="all">
                                    <RadioButton.Template>
                                        <ControlTemplate TargetType="RadioButton">
                                            <Grid Name="gr" Height="40">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition />
                                                    <ColumnDefinition />
                                                    <ColumnDefinition Width="0.5*" />
                                                </Grid.ColumnDefinitions>

                                                <ComboBox
                                                    Name="cb"
                                                    Grid.Column="0"
                                                    Margin="3,1"
                                                    VerticalAlignment="Center"
                                                    BorderBrush="#FF074B92"
                                                    BorderThickness="1"
                                                    FontFamily="楷体"
                                                    FontSize="20"
                                                    Foreground="#FF2AB2E7"
                                                    IsEditable="False"
                                                    ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
                                                    SelectedIndex="0"
                                                    Style="{StaticResource ComboBoxStyle}"
                                                    Text="{Binding RawMaterialName}" />

                                                <!--<TextBox
                                                    Name="cb"
                                                    Grid.Column="0"
                                                    Margin="3,1"
                                                    VerticalAlignment="Center"
                                                    BorderBrush="#FF074B92"
                                                    BorderThickness="1"
                                                    FontFamily="楷体"
                                                    FontSize="20"
                                                    Foreground="#FF2AB2E7"
                                                    Text="{Binding RawMaterialName}" />-->
                                                <StackPanel
                                                    Grid.Column="1"
                                                    VerticalAlignment="Center"
                                                    Orientation="Horizontal">
                                                    <TextBox
                                                        Name="tb"
                                                        Grid.Column="1"
                                                        Width="150"
                                                        Height="29"
                                                        Margin="3,1"
                                                        VerticalAlignment="Center"
                                                        FontSize="20"
                                                        Text="{Binding RawMaterialWeight}" />

                                                    <TextBlock
                                                        Grid.Column="1"
                                                        Margin="0,0,8,4"
                                                        HorizontalAlignment="Right"
                                                        VerticalAlignment="Center"
                                                        Text="mg" />

                                                </StackPanel>

                                                <Button
                                                    Grid.Column="2"
                                                    Margin="10,0,10,0"
                                                    Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
                                                    CommandParameter="{Binding RawMaterialId}"
                                                    Content="删除" />

                                            </Grid>


                                        </ControlTemplate>
                                    </RadioButton.Template>
                                </RadioButton>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>

            </Grid>

        </Grid>
    </Border>
</Window>
