demo_trade/Views/GuestProductControl.axaml

66 lines
3.2 KiB
Plaintext
Raw Normal View History

2024-10-04 12:41:04 +00:00
<UserControl 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"
xmlns:vm="using:demo_trade.ViewModels"
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
xmlns:conv="using:demo_trade.UI.Converters"
x:DataType="vm:GuestProductViewModel"
x:Class="demo_trade.GuestProductControl">
<UserControl.Resources>
<conv:ItemColorConverter x:Key="itemColorConverter"/>
</UserControl.Resources>
<Grid ColumnDefinitions="*" RowDefinitions="50, *, 50" ShowGridLines="True">
<StackPanel
Margin="5"
Orientation="Horizontal"
DockPanel.Dock="Top"
HorizontalAlignment="Center"
Grid.Row="0"
Spacing="10">
<TextBlock Text="{Binding StatisticText}"/>
<TextBox Text="{Binding SearchWord}" MinWidth="200"/>
<ComboBox MinWidth="100" SelectedIndex="{Binding SelectedFilterValue}">
<ComboBoxItem>Все диапазоны</ComboBoxItem>
<ComboBoxItem>0-9.99%</ComboBoxItem>
<ComboBoxItem>10-14.99%</ComboBoxItem>
<ComboBoxItem>15% и болле</ComboBoxItem>
</ComboBox>
<ComboBox MinWidth="100" SelectedIndex="{Binding SelectedSortValue}">
<ComboBoxItem>отсут.</ComboBoxItem>
<ComboBoxItem>по убыв.</ComboBoxItem>
<ComboBoxItem>по возраст.</ComboBoxItem>
</ComboBox>
</StackPanel>
<ListBox ItemsSource="{Binding Products}" Padding="15" Grid.Row="1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel ContextMenu="" Orientation="Horizontal" Spacing="10" Background="{Binding DiscountAmount, Converter={StaticResource itemColorConverter}}">
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding $parent[ListBox].((vm:GuestProductViewModel)DataContext).AddToOrderCommand}" CommandParameter="{Binding}" Header="Добавить в заказ"/>
</ContextMenu>
</StackPanel.ContextMenu>
<Image asyncImageLoader:ImageLoader.Source="{Binding Image}" Height="50" Width="50"/>
<StackPanel Orientation="Vertical" >
<TextBlock Text="{Binding Name, StringFormat='Название товара: {0}'}"/>
<TextBlock Text="{Binding Description, StringFormat='Описание товара: {0}'}"/>
<TextBlock Text="{Binding Manufacturer.Name, StringFormat='Производитель товара: {0}' }"/>
</StackPanel>
<Border BorderBrush="Black" BorderThickness="2">
<TextBlock Text="{Binding DiscountAmount, StringFormat='Скидка: {0}%'}"/>
</Border>
<TextBlock Text="{Binding Cost, StringFormat='Цена: {0}'}"/>
<TextBlock Text="{Binding CostWithDiscount, StringFormat='Цена с учетом скидки: {0}'}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="2">
<Button Content="Перейти к заказу" IsVisible="{Binding ThereItemsInOrder}" Command="{Binding AttachToOrderCommand}" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
</StackPanel>
</Grid>
</UserControl>