<UserControl
    x:Class="BPA.SingleDevice.View.OrderMainView"
    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:OrderMainViewModel />
    </UserControl.DataContext>

    <Grid Margin="10">
        <ListView
            VerticalAlignment="Top"
            bpa:ItemsControlHelper.ItemPadding="8 0 0 0"
            ItemsSource="{Binding Goods}">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="5" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <bpa:ControlDisplay Margin="5">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="120" />
                                <RowDefinition Height="40" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Border Width="120" Background="Gray" />
                            <TextBlock
                                Grid.Row="1"
                                HorizontalAlignment="Center"
                                FontSize="16"
                                Foreground="#ddd"
                                Text="{Binding Name}" />
                            <Border
                                Grid.Row="1"
                                BorderBrush="#505050"
                                BorderThickness="0,0,0,1" />
                            <Grid
                                Grid.Row="2"
                                Margin="0,5,0,0"
                                bpa:GridHelper.ColumnDefinitions="*,*">
                                <bpa:NumericBox
                                    bpa:ControlHelper.FocusBorderBrush="{DynamicResource Secondary}"
                                    BorderThickness="0"
                                    IsReadOnly="True"
                                    Style="{StaticResource FrontBackNumericBox}"
                                    Value="{Binding Count}" />
                                <Button
                                    Grid.Column="1"
                                    Margin="10,0,0,0"
                                    Command="{Binding DataContext.DownRecipeCommand, RelativeSource={RelativeSource AncestorType=local:OrderMainView}}"
                                    CommandParameter="{Binding Id}"
                                    Content="开始下单"
                                    Foreground="#ddd"
                                    Style="{DynamicResource SecondaryButton}" />
                            </Grid>
                        </Grid>
                    </bpa:ControlDisplay>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</UserControl>
