<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: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:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
    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="40" />
            <RowDefinition />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>

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

        <ScrollViewer Grid.Row="1">
            <ListView ItemsSource="{Binding NewRecipeModels}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid Columns="2" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid
                            Margin="5,0,0,0"
                            HorizontalAlignment="Right"
                            bpa:GridHelper.ColumnDefinitions="Auto,Auto">
                            <CheckBox
                                Margin="10,5"
                                Content="{Binding Name}"
                                FontSize="16"
                                IsChecked="{Binding IsChecked}" />
                            <TextBox
                                Grid.Column="1"
                                Width="100"
                                IsEnabled="{Binding IsChecked}"
                                Text="{Binding Weight}" />
                        </Grid>
                    </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="确认" />
            <Button
                Grid.Column="1"
                Command="{Binding CancelCommand}"
                Content="取消" />
        </Grid>

    </Grid>
</UserControl>
