<UserControl
    x:Class="BPA.SingleDevice.View.NewRecipeView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:BPA.SingleDevice.View"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">

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

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <Grid Margin="10,0" bpa:GridHelper.Columns="2">
            <TextBlock FontSize="40" Text="配方名称：" />
            <TextBox
                Grid.Column="1"
                Margin="0,5"
                FontSize="40"
                Style="{StaticResource DarkTextBox}"
                Text="{Binding RecipeName}" />
        </Grid>

        <ScrollViewer
            Grid.Row="1"
            Width="950"
            Height="700"
            bpa:ScrollViewerHelper.ScrollBarSize="40">
            <ListView ItemsSource="{Binding NewRecipeModels}" >
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid Columns="2" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <UniformGrid
                            Width="450"
                            Height="50"
                            Margin="5,0,0,0"
                            HorizontalAlignment="Right"
                            bpa:GridHelper.ColumnDefinitions="Auto,Auto"
                            Columns="2">
                            <CheckBox
                                Margin="10,5"
                                Content="{Binding Name}"
                                FontSize="32"
                                IsChecked="{Binding IsChecked}" />
                            <TextBox
                                Grid.Column="1"
                                Width="140"
                                FontSize="32"
                                IsEnabled="{Binding IsChecked}"
                                Text="{Binding Weight}" />
                        </UniformGrid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </ScrollViewer>

        <Grid
            Grid.Row="2"
            Margin="0,5"
            bpa:GridHelper.ColumnDefinitions="*,*"
            bpa:PanelHelper.Spacing="10">
            <Button
                Grid.Column="0"
                Command="{Binding SaveCommand}"
                Content="确认"
                FontSize="40" />
            <Button
                Grid.Column="1"
                Command="{Binding CancelCommand}"
                Content="取消"
                FontSize="40" />
        </Grid>
    </Grid>
</UserControl>