generated from admin/template
verstka
This commit is contained in:
@@ -11,9 +11,6 @@ public partial class App : Application
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
#if DEBUG
|
|
||||||
this.AttachDeveloperTools();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
@@ -25,18 +22,6 @@ public partial class App : Application
|
|||||||
DataContext = new MainViewModel()
|
DataContext = new MainViewModel()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime)
|
|
||||||
{
|
|
||||||
singleViewFactoryApplicationLifetime.MainViewFactory =
|
|
||||||
() => new MainView { DataContext = new MainViewModel() };
|
|
||||||
}
|
|
||||||
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
|
|
||||||
{
|
|
||||||
singleViewPlatform.MainView = new MainView
|
|
||||||
{
|
|
||||||
DataContext = new MainViewModel()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
namespace demo.ViewModels
|
||||||
|
|
||||||
namespace demo.ViewModels;
|
|
||||||
|
|
||||||
public partial class MainViewModel : ViewModelBase
|
|
||||||
{
|
{
|
||||||
[ObservableProperty] public partial string Greeting { get; set; } = "Welcome to Avalonia!";
|
public class MainViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
|
||||||
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"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="demo.Views.MainWindow"
|
|
||||||
Title="DemoApp">
|
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto, *" Margin="20">
|
|
||||||
|
|
||||||
<Grid Grid.Row="0"
|
|
||||||
ColumnDefinitions="*, Auto, Auto"
|
|
||||||
ColumnSpacing="10"
|
|
||||||
Margin="0,0,0,20">
|
|
||||||
|
|
||||||
<TextBox Grid.Column="0"
|
|
||||||
Watermark="Введите для поиска"
|
|
||||||
HorizontalAlignment="Stretch" />
|
|
||||||
|
|
||||||
<ComboBox Grid.Column="1"
|
|
||||||
PlaceholderText="Сортировка"
|
|
||||||
MinWidth="120"
|
|
||||||
HorizontalAlignment="Stretch" />
|
|
||||||
|
|
||||||
<ComboBox Grid.Column="2"
|
|
||||||
PlaceholderText="Фильтрация"
|
|
||||||
MinWidth="120"
|
|
||||||
HorizontalAlignment="Stretch" />
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Border Grid.Row="1"
|
|
||||||
BorderBrush="Gray"
|
|
||||||
BorderThickness="2"
|
|
||||||
CornerRadius="8"
|
|
||||||
Background="#F9F9F9">
|
|
||||||
|
|
||||||
<StackPanel Orientation="Vertical"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Spacing="10">
|
|
||||||
|
|
||||||
<TextBlock Text="Каталог продуктов"
|
|
||||||
FontSize="24"
|
|
||||||
HorizontalAlignment="Center" />
|
|
||||||
|
|
||||||
<TextBlock Text="Здесь будет список продуктов"
|
|
||||||
FontSize="18"
|
|
||||||
Foreground="Gray"
|
|
||||||
HorizontalAlignment="Center" />
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
|
|
||||||
namespace demo.Views;
|
|
||||||
|
|
||||||
public partial class MainView : UserControl
|
|
||||||
{
|
|
||||||
public MainView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,37 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:demo.ViewModels"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:views="using:demo.Views"
|
xmlns:models="clr-namespace:demo.Models"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="500"
|
||||||
x:Class="demo.Views.MainWindow"
|
x:Class="demo.Views.MainWindow"
|
||||||
Icon="/Assets/avalonia-logo.ico"
|
Title="Каталог товаров">
|
||||||
Title="demo">
|
|
||||||
<views:MainView />
|
<Grid RowDefinitions="Auto, *" Margin="20">
|
||||||
</Window>
|
|
||||||
|
<!-- Топ-бар: Поиск, Сортировка, Фильтрация -->
|
||||||
|
<Grid Grid.Row="0" ColumnDefinitions="*, Auto, Auto" ColumnSpacing="10" Margin="0,0,0,20">
|
||||||
|
<TextBox Grid.Column="0" PlaceholderText="Введите для поиска" HorizontalAlignment="Stretch" />
|
||||||
|
<ComboBox Grid.Column="1" PlaceholderText="Сортировка" MinWidth="120" HorizontalAlignment="Stretch" />
|
||||||
|
<ComboBox Grid.Column="2" PlaceholderText="Фильтрация" MinWidth="120" HorizontalAlignment="Stretch" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Список товаров из базы данных -->
|
||||||
|
<ListBox Grid.Row="1" x:Name="ProductList">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type models:IdProduct}">
|
||||||
|
<Grid ColumnDefinitions="Auto, *" Margin="8">
|
||||||
|
<Border Grid.Column="0" Width="80" Height="80" Background="#E0E0E0" CornerRadius="4">
|
||||||
|
<TextBlock Text="Фото" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
|
</Border>
|
||||||
|
<StackPanel Grid.Column="1" Margin="12,0,0,0" VerticalAlignment="Center" Spacing="4">
|
||||||
|
<!-- Выводит текстовое представление объекта товара -->
|
||||||
|
<TextBlock Text="{Binding}" FontWeight="SemiBold" FontSize="16" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -1,11 +1,27 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Linq;
|
||||||
|
using demo.Models;
|
||||||
|
|
||||||
namespace demo.Views;
|
namespace demo.Views
|
||||||
|
|
||||||
public partial class MainWindow : Window
|
|
||||||
{
|
{
|
||||||
public MainWindow()
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
LoadProducts();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadProducts()
|
||||||
|
{
|
||||||
|
using var context = new PostgresContext();
|
||||||
|
|
||||||
|
// Загружаем список товаров из PostgreSQL через EF Core
|
||||||
|
var products = context.IdProducts.ToList();
|
||||||
|
|
||||||
|
// Передаем данные в элемент ListBox на форме
|
||||||
|
ProductList.ItemsSource = products;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user