<Window x:Class="wpf_connection3.Windows.EditProductWindow"
        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:wpf_connection3.Windows"
        mc:Ignorable="d"
        Title="EditProductWindow" Height="600" Width="800"
         Name="root">

    <Grid>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>


        
        <StackPanel>
            <Image
Name="CurrentProductImage"
Width="200" 
Height="200"
Source="{Binding currentProduct.ImageBitmap}" />
            <ListView
                Name="ProductMaterialListView"
                ItemsSource="{Binding productMaterialList}">
            <ListView.ItemContainerStyle>
                <Style
                        TargetType="ListViewItem">
                    <Setter
                            Property="HorizontalAlignment"
                            Value="Stretch"/>
                </Style>
            </ListView.ItemContainerStyle>

            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="15"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock
                                Text="{Binding Title}"/>
                        <TextBlock
                                Grid.Column="1"
                                Margin="15,0"
                                HorizontalAlignment="Right"
                                Text="{Binding Count}"/>
                        <TextBlock
                                x:Name="DeleteMaterialTextBox"
                                Grid.Column="2"
                                HorizontalAlignment="Right"
                                Tag="{Binding Path=.}"
                                Text="🗑"
                                MouseDown="DeleteMaterialTextBox_MouseDown"
                           />
                    </Grid>
                </DataTemplate>

            </ListView.ItemTemplate>
        </ListView>
            <Button
                x:Name="AddMaterialButton"
                Content="✚"
                Height="50"
                Click="AddMaterialButton_Click"/>
        </StackPanel>



        <StackPanel
      Grid.Column="1"
            Margin="5">

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

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

            <Label Content="Тип продукта"/>
            <ComboBox
                Name="ProductTypeComboBox"
                ItemsSource="{Binding productTypeList}"
                SelectedIndex="{Binding selectedProductIndex}"/>

            <Label Content="Количество человек для производства"/>
            <TextBox 
                Name="ProductionPersonCountTextBox"
                Text="{Binding currentProduct.ProductionPersonCount}"/>

            <Label Content="Номер производственного цеха"/>
            <TextBox 
                Name="ProductionWorkshopNumberTextBox"
                Text="{Binding currentProduct.ProductionWorkshopNumber}"/>

            <Label Content="Минимальная стоимость для агента"/>
            <TextBox
                Name="MinCostForAgentTextBox"
                Text="{Binding currentProduct.MinCostForAgent}"/>

            <Label Content="Описание продукта"/>
            <TextBox
                Name="DescriptionTextBox"
                AcceptsReturn="True"
                Height="200"
                Text="{Binding currentProduct.Descrpition}"/>

            <Button
                Name="ChangeImageButton"
                Content="Изменить фото"
                Margin="5"
                Click="ChangeImageButton_Click"/>

            <Button
                Name="SaveButton"
                Content="Сохранить"
                Margin="5"
                Click="SaveButton_Click"/>

            <Button
                Name="deleteButton"
                Content="Удалить продукт"
                Margin="5"
                Click="deleteButton_Click"/>

        </StackPanel>

    </Grid>
</Window>