<Window x:Class="mysql_connector2.Windows.CostWindow"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:mysql_connector2.Windows"
        mc:Ignorable="d"
        Title="CostWindow" Height="450" Width="800" Name="root">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        <StackPanel
    Grid.Column="1" 
    Margin="5">

            <Label Content="Артикул"/>
            <TextBox
        Text="{Binding currentProduct.ArticleNumber}"/>

            <Label Content="Наименование продукта"/>
            <TextBox Text="{Binding currentProduct.Title}"/>

            <ComboBox 
            Name="ProductTypeComboBox"
    ItemsSource="{Binding productTypeList}"
    SelectedIndex="{Binding selectedProductIndex}"/>

            <Label Content="количество человек для производства"/>
            <TextBox 
AcceptsReturn="True"
Text="{Binding currentProduct.ProductionPersonCount}"/>
            <Label Content="номер производственного цеха"/>
            <TextBox 
AcceptsReturn="True"
Text="{Binding currentProduct.ProductionWorkshopNumber}"/>
            <Label Content="минимальная стоимость для агента"/>
            <TextBox 
AcceptsReturn="True"
Text="{Binding currentProduct.MinCostForAgent}"/>
            <Label Content="Описание продукта"/>
            <TextBox 
AcceptsReturn="True"
Height="50"
Text="{Binding currentProduct.Description}"/>
        </StackPanel>
        <StackPanel Grid.Column="0" Orientation="Vertical" HorizontalAlignment="Right" Margin="0,5,5,5">
            <Image
Name="CurrentProductImage"
Width="200" 
Height="200"
Source="{Binding currentProduct.ImageBitmap}" />
            <Button Height="20" Content="Сменить картинку" Click="ChangeImage_Click" />
            <Button Height="20" Content="Удалить" Click="DeleteProductButton_Click" 
                    Visibility="{Binding DeleteProductVisibly}"/>
            <Button Height="20" Content="Сохранить" Click="SaveButton_Click" />
            <Button Content="+" Click="AddMaterialButton_Click"/>
            <StackPanel Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Horizontal" Margin="2">
                <TextBlock Text="Поиск материалов:" Margin="10, 0, 5, 0" />
                <TextBox x:Name="SearchTextBox" Margin="0, 0,0,0" Width="105" TextChanged="SearchTextBox_TextChanged" />
            </StackPanel>
            <ListView
            x:Name="ProductMaterialsListView"
ItemsSource="{Binding productMaterialList}"
MouseDoubleClick="ListView_MouseDoubleClick"
             Grid.Row="5" Grid.Column="1" Margin="10">
                <ListView.ItemContainerStyle>
                    <Style 
        TargetType="ListViewItem"
    >
                        <Setter 
            Property="HorizontalContentAlignment"
            Value="Stretch" />
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock 
                Text="{Binding MaterialTitle}"/>
                            <TextBlock     
                Grid.Column="1" 
                Margin="10,0"
                Text="{Binding Count}"/>
                            <TextBlock
                x:Name="DeleteMaterialTextBlock" 
                Grid.Column="2"
                Tag="{Binding Path=.}"
                Text="Туда его" 
                MouseDown="DeleteMaterialTextBlock_MouseDown"/>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

        </StackPanel>
    </Grid>
</Window>
