presence/Presence.Desktop/Views/MainWindow.axaml
2024-12-12 10:20:21 +03:00

71 lines
3.5 KiB
XML

<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Presence.Desktop.ViewModels"
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="Presence.Desktop.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="Presence.Desktop">
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<DockPanel>
<StackPanel
Spacing="10"
HorizontalAlignment="Center"
DockPanel.Dock="Top"
Orientation="Horizontal">
<ComboBox ItemsSource="{Binding Groups}"
SelectedValue="{Binding SelectedGroupItem}"
DisplayMemberBinding="{Binding Name}"
SelectedValueBinding="{Binding}"
/>
<Button Width="140" HorizontalContentAlignment="Center" Content="Внести студентов" Command="{Binding OpenFileDialog}"/>
<ComboBox ItemsSource="{Binding Sorting}" SelectedItem="{Binding SelectedSort}"/>
<Button HorizontalAlignment="Right" Content="Удалить всех студентов" Command="{Binding DeleteAllCommand}"/>
</StackPanel>
<Border>
<ListBox Name="StudentListBox" SelectionMode="Multiple" Selection="{Binding Selection}" ItemsSource="{Binding Students}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem IsVisible="{Binding !#StudentListBox.((vm:MainWindowViewModel)DataContext).MultipleSelected}"
Command="{Binding #StudentListBox.((vm:MainWindowViewModel)DataContext).EditCommand}"
Header="Изменить"/>
<MenuItem IsVisible="{Binding !#StudentListBox.((vm:MainWindowViewModel)DataContext).MultipleSelected}"
Command="{Binding #StudentListBox.((vm:MainWindowViewModel)DataContext).DeleteCommand}"
Header="Удалить"/>
<MenuItem IsVisible="{Binding #StudentListBox.((vm:MainWindowViewModel)DataContext).MultipleSelected}"
Command="{Binding #StudentListBox.((vm:MainWindowViewModel)DataContext).DeleteSelectedCommand}"
Header="Удалить выделенные"/>
</ContextMenu>
</StackPanel.ContextMenu>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1} {2}">
<Binding Path="LastName"/>
<Binding Path="FirstName"/>
<Binding Path="Patronymic"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</DockPanel>
</Window>