Sin descripción

sbakhtina b71acc05ef Загрузить файлы 'img' hace 6 meses
WpfApp1 eb82d7968a 2st commit hace 6 meses
img b71acc05ef Загрузить файлы 'img' hace 6 meses
.gitignore.txt 4b0a6ae650 1st commit hace 8 meses
README.md 519f1485c5 Обновить 'README.md' hace 6 meses

README.md

Class1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp1.model
{
    public class Place
    {
        public string name { get; set; }
        public int price { get; set; }
        public string category { get; set; }
        public string photo { get; set; }
    }
    class Client
    {
        public string name { get; set; }
        public int age { get; set; }
    }

}

Class2

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp1.model
{
    class Globals
    {
        public static IDataProvider dataProvider;
    }
}

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 WpfApp1.model;

namespace WpfApp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>

    public partial class MainWindow : Window
    {
        public IEnumerable<Place> PlaceList { get; set; }
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
            Globals.dataProvider = new LocalDataProvider();
            PlaceList = Globals.dataProvider.getPlace();
        }

        private void ExitButton_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();

        }
    }
    interface IDataProvider
    {
        IEnumerable<Place> getPlace();
    }
    public class LocalDataProvider : IDataProvider
    {
        public IEnumerable<Place> getPlace()
        {
            return new Place[]{
            new Place{
                price=2300,
                category="По России",
                name="Москва"},
            new Place{
                price=5000,
                category="По России",
                name="Сочи"},
            new Place{
                price=15000,
                category="За границей",
                name="Токио"},
        };

        }
    }
}

Mainwindow.xaml

<Window x:Class="WpfApp1.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:WpfApp1"
        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>

        <!-- типа логотип компании -->
        <Image 
        Source="./img/1.jpg" 
        Grid.RowSpan="2" HorizontalAlignment="Right"/>
        <DataGrid
    Grid.Row="1"
    Grid.Column="1"
    CanUserAddRows="False"
    AutoGenerateColumns="False"
    ItemsSource="{Binding PlaceList}">
            <DataGrid.Columns>
                <DataGridTextColumn
            Header="Место"
            Binding="{Binding name}"/>
                <DataGridTextColumn
            Header="Цена"
            Binding="{Binding price}"/>
                <DataGridTextColumn
            Header="Категория"
            Binding="{Binding category}"/>
            </DataGrid.Columns>
        </DataGrid>
        <StackPanel 
        Orientation="Vertical"
        Grid.RowSpan="3"
        VerticalAlignment="Bottom">
            <Button 
            x:Name="ExitButton"
            Content="Выход" 
            Click="ExitButton_Click"
            Height="50"/>
        </StackPanel>

        <WrapPanel
        Orientation="Horizontal"
        Grid.Column="1"
        MinHeight="50">
            <!-- минимальную высоту я тут поставил, чтобы верхнюю строку сетки было видно. В реальном приложении она не нужна -->
        </WrapPanel>
    </Grid>
</Window>