Nincs leírás

al 2d0b7ab903 1 1 hónapja
.vs 2d0b7ab903 1 1 hónapja
fy 2d0b7ab903 1 1 hónapja
wpf_connection3 2d0b7ab903 1 1 hónapja
readme.md 2d0b7ab903 1 1 hónapja
wpf_connection3.sln 2d0b7ab903 1 1 hónapja

readme.md

Создание подключения к БД MySQL. Получение данных с сервера.

MainWindow.xaml.cs

using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Dapper;
using MySqlConnector;

namespace wpf_connection3
{


    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

<Window x:Class="wpf_connection3.MainWindow"
        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"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <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="logotire/extasy.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>