## Создание подключения к БД MySQL. Получение данных с сервера.
#### MainWindow.xaml.cs
```
namespace mysql_connector2
{
    public partial class MainWindow : Window
    {
        public List<Product> productList { get; set; }
        private void ExitButton_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();

        }
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
            Globals.dataProvider = new DBDataProvider();
            productList = (List<Product>)Globals.dataProvider.getProduct();
        }

    }
}
```
#### MainWindow.xaml
```
    <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition />
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>


        <ListBox 
Grid.Row="1"
Grid.Column="1"
Background="White"
ItemsSource="{Binding productList}" 
            ScrollViewer.HorizontalScrollBarVisibility="Disabled" Margin="3,3,0,0"  RenderTransformOrigin="0.5,0.5">

            <ListBox.ItemContainerStyle>
                <Style 
            TargetType="ListBoxItem">
                    <Setter 
                Property="HorizontalContentAlignment"
                Value="Stretch" />
                </Style>
            </ListBox.ItemContainerStyle>

            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border 
        BorderThickness="1" 
        BorderBrush="Black" 
        CornerRadius="5">

                        <Grid 
Margin="10" 
HorizontalAlignment="Stretch">

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

                            <Image
                            Width="64" 
                            Height="64"
                            Source="{Binding ImageBitmap}" HorizontalAlignment="Center"/>

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

                                <TextBlock
                                Text="{Binding Title}"/>
                                <TextBlock
                                Text="{Binding ArticleNumber}"/>
                            </StackPanel>

                            <TextBlock
                            Grid.Column="2"
                        Text="{Binding ProductTypeID}"/>

                        </Grid>

                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

        <Image 
        Source="/logo/Logo.jpg" 
        Grid.RowSpan="2"/>
        <StackPanel 
        Orientation="Vertical"
        Grid.RowSpan="3"
        VerticalAlignment="Bottom">
            <Button 
            x:Name="ExitButton"
            Content="Выход" 
            Click="ExitButton_Click"
            Height="54"/>
        </StackPanel>

        <WrapPanel
        Orientation="Horizontal"
        Grid.Column="1"
        MinHeight="50">
        </WrapPanel>

    </Grid>
</Window>
```
![](./img/1.jpg)