<UserControl
    x:Class="BPA.SingleDevice.View.SetBindMaterialView"
    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:conv="clr-namespace:BPA.SingleDevice.Converters"
    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="300"
    d:DesignWidth="800"
    mc:Ignorable="d">

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

    <UserControl.Resources>
        <conv:MateialCodeConverter x:Key="MateialCodeConverter" />
    </UserControl.Resources>

    <Grid Margin="10" bpa:PanelHelper.Spacing="10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="320" />
            <ColumnDefinition />
            <ColumnDefinition Width="320" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>

        <TextBlock
            Grid.Row="0"
            Grid.Column="0"
            HorizontalAlignment="Right"
            FontSize="40"
            Foreground="#ddd"
            Text="物料编码：" />
        <TextBox
            Grid.Row="0"
            Grid.Column="1"
            Height="70"
            FontSize="40"
            IsReadOnly="True"
            Style="{StaticResource DarkTextBox}"
            Text="{Binding ElementName=MaterialSelectList, Path=SelectedItem.MaterialCode}" />

        <TextBlock
            Grid.Row="0"
            Grid.Column="2"
            HorizontalAlignment="Right"
            FontSize="40"
            Foreground="#ddd"
            Text="对应物料名称：" />
        <TextBox
            Grid.Row="0"
            Grid.Column="3"
            Height="70"
            FontSize="40"
            IsReadOnly="True"
            Style="{StaticResource DarkTextBox}"
            Text="{Binding ElementName=MaterialSelectList, Path=SelectedItem.Name}" />

        <TextBlock
            Grid.Row="1"
            Grid.Column="0"
            HorizontalAlignment="Right"
            FontSize="40"
            Foreground="#ddd"
            Text="设备对应工位：" />
        <ComboBox
            Grid.Row="1"
            Grid.Column="1"
            Height="70"
            FontSize="40"
            ItemsSource="{Binding DeviceNums}"
            SelectedIndex="0"
            Text="{Binding RawMaterResultInfo.DeviceNum}" />

        <TextBlock
            Grid.Row="1"
            Grid.Column="2"
            HorizontalAlignment="Right"
            FontSize="40"
            Foreground="#ddd"
            Text="设备通道编号：" />
        <ComboBox
            Grid.Row="1"
            Grid.Column="3"
            Height="70"
            FontSize="40"
            ItemsSource="{Binding ChNum}"
            SelectedIndex="0"
            Style="{StaticResource LargeScrollComboBoxStyle}"
            Text="{Binding RawMaterResultInfo.WarehouseNum}" />

        <bpa:ControlDisplay
            Grid.Row="2"
            Grid.RowSpan="4"
            Grid.Column="0"
            Grid.ColumnSpan="4">
            <!--<ScrollViewer bpa:ScrollViewerHelper.ScrollBarSize="40">-->
            <ListView
                x:Name="MaterialSelectList"
                Margin="10"
                ItemsSource="{Binding MaterialInfos}"
                SelectedItem="{Binding SelectedItem}"
                SelectionMode="Single"
                bpa:ItemsControlHelper.ItemMargin="5"
                Style="{StaticResource LargeScrollListView}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid Columns="3" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <!--<RadioButton FontSize="32" GroupName="MaterialGroup">
                                <RadioButton.Content>-->
                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" MinWidth="190" />
                            </Grid.ColumnDefinitions>
                            <TextBlock FontSize="32" Text="{Binding Name}" />
                            <TextBlock
                                Grid.Column="1"
                                Margin="10,0,0,0"
                                FontSize="32"
                                Text="{Binding MaterialCode, StringFormat=({0})}" />
                        </Grid>
                        <!--</RadioButton.Content>
                            </RadioButton>-->
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            <!--</ScrollViewer>-->
        </bpa:ControlDisplay>


        <Grid
            Grid.Row="6"
            Grid.ColumnSpan="4"
            Height="70"
            Margin="0,5"
            bpa:PanelHelper.Spacing="10">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Button
                Grid.Column="0"
                Command="{Binding SaveCommand}"
                Content="确认"
                FontSize="40" />
            <Button
                Grid.Column="1"
                Command="{Binding CancelCommand}"
                Content="取消"
                FontSize="40" />
        </Grid>
    </Grid>
</UserControl>
