123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <Page x:Class="InvestTracker.Views.EmployeeBrowseView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:vm="clr-namespace:InvestTracker.VM"
- xmlns:local="clr-namespace:InvestTracker.Views"
- xmlns:model="clr-namespace:InvestTracker.Entities"
- xmlns:validation="clr-namespace:InvestTracker.Validation" d:DataContext="{d:DesignInstance Type=vm:EmployeeBrowseVM}"
- mc:Ignorable="d"
- d:DesignHeight="450" d:DesignWidth="800"
- x:Name="EPage"
- Title="EmployeeBrowseView">
- <Page.Resources>
- <!--Шаблон яйчейки отображения даты-->
- <DataTemplate x:Key="RegularDateTemplate" >
- <TextBlock
- Text="{Binding Birthday,StringFormat={}{0:dd\.}{0:MM\.}{0:yyyy}}"
- VerticalAlignment="Center"
- HorizontalAlignment="Center" />
- </DataTemplate>
- <!--Шаблон яйчейки редактирования даты-->
- <DataTemplate x:Key="EditingDateTemplate">
- <DatePicker SelectedDate="{Binding Birthday, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
- </DataTemplate>
-
- <!--BTV-->
- <BooleanToVisibilityConverter x:Key="BTV"/>
- </Page.Resources>
- <StackPanel>
- <!--Этот FrameworkElement содержит все свойства у Page-->
- <FrameworkElement x:Name="ProxyElement" DataContext="{Binding}" Visibility="Collapsed"/>
-
- <Menu>
- <MenuItem Header="Действие" >
- <MenuItem Command="{Binding UndoCommand}" Header="Отменить" ></MenuItem>
- <Separator/>
- <MenuItem Command="{Binding NewCommand}" Header="Создать" ></MenuItem>
- <MenuItem Command="{Binding EditCommand}" Header="Редактировать" ></MenuItem>
- <MenuItem Command="{Binding SaveCommand}" Header="Сохранить" ></MenuItem>
- <MenuItem Command="{Binding FindCommand}" Header="Найти" />
- <Separator/>
- <MenuItem Command="{Binding DeleteCommand}" Header="Удалить" ></MenuItem>
- </MenuItem>
- <MenuItem Header="Отчет"></MenuItem>
- </Menu>
- <Label HorizontalAlignment="Center" FontSize="24">Список сотрудников</Label>
-
- <ToolBar Margin="8">
- <Button Name="Undo" Command="{Binding UndoCommand}" ToolTip="Отменить редактирование/создание">
- <Image Width="32" Height="32" Source="/Images/undo.png" />
- </Button>
- <Button Name="Add" Command="{Binding NewCommand}" ToolTip="Добавить">
- <Image Width="32" Height="32" Source="/Images/add.png" />
- </Button>
- <Button Name="Edit" Command="{Binding EditCommand}" ToolTip="Редактировать">
- <Image Width="32" Height="32" Source="/Images/edit.png" />
- </Button>
- <Button Name="Search" Command="{Binding ToggleFilterCommand}" ToolTip="Поиск">
- <Image Width="32" Height="32" Source="/Images/search.png" />
- </Button>
- <Button Name="Save" Command="{Binding SaveCommand}" ToolTip="Сохранить">
- <Image Width="32" Height="32" Source="/Images/save.png" />
- </Button>
- <Button Name="Delete" Command="{Binding DeleteCommand}" ToolTip="Удалить">
- <Image Width="32" Height="32" Source="/Images/delete.png" />
- </Button>
- </ToolBar>
- <!--Main-->
- <StackPanel>
-
- <!--Поле поиска-->
- <Grid
- Visibility="{Binding FilterActive,Converter={StaticResource BTV}}"
- Grid.Column="1"
- Background="#ddd"
- Margin="8">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="64"/>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="32"/>
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="16"/>
- <RowDefinition Height="32"/>
- <RowDefinition Height="32"/>
- </Grid.RowDefinitions>
- <Label
- Content="Поиск"
- HorizontalAlignment="Center"
- Grid.Column="0"
- Grid.ColumnSpan="3"
- Grid.Row="0"/>
- <Label
- Content="Фамилия"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Grid.Column="0"
- Grid.Row="1"/>
- <TextBox
- VerticalContentAlignment="Center"
- Grid.Column="1"
- Margin="4"
- Grid.Row="1"
- Text="{Binding FilterSurname,UpdateSourceTrigger=PropertyChanged}"/>
- <Button
- Command="{Binding FindCommand}"
- Grid.Column="2"
- Grid.Row="1"
- Grid.RowSpan="2"
- Margin="4"
- ToolTip="Поиск">
- <Image Source="/Images/search.png" />
- </Button>
- <Label
- Content="Должность"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Grid.Column="0"
- Grid.Row="2"/>
- <ComboBox
- VerticalContentAlignment="Center"
- Margin="4"
- Grid.Column="1"
- Grid.Row="2"
- ItemsSource="{Binding DataContext.AllTitles,Source={x:Reference ProxyElement}}"
- DisplayMemberPath="Name"
- SelectedItem="{Binding FilterTitle, UpdateSourceTrigger=PropertyChanged}"/>
- </Grid>
- <!--/Поле поиска-->
-
- <!--Сетка редактирования-->
- <DataGrid
- Margin="8"
- Grid.Column="0"
- AutoGenerateColumns="False"
- ItemsSource="{Binding Employees}"
- RowBackground="#ddd"
- AlternatingRowBackground="#eee"
- CanUserAddRows="False"
- CanUserDeleteRows="False"
- IsReadOnly="{Binding GridBlocked}"
- SelectedItem="{Binding SelectedEmployee}">
- <!--Рисуем восклицательный знак если в строке ошибка-->
- <DataGrid.RowValidationErrorTemplate>
- <ControlTemplate>
- <Grid
- Margin="0,-2,0,-2"
- ToolTip="{Binding
- RelativeSource={RelativeSource FindAncestor,
- AncestorType={x:Type DataGridRow}},
- Path=(Validation.Errors)[0].ErrorContent}">
- <Ellipse
- StrokeThickness="0"
- Fill="Red"
- Width="{TemplateBinding FontSize}"
- Height="{TemplateBinding FontSize}" />
- <TextBlock
- Text="!"
- FontSize="{TemplateBinding FontSize}"
- FontWeight="Bold"
- Foreground="White"
- HorizontalAlignment="Center" />
- </Grid>
- </ControlTemplate>
- </DataGrid.RowValidationErrorTemplate>
- <DataGrid.Columns>
- <DataGridTextColumn
- Binding="{Binding Path=Surname,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
- Header="Фамилия"/>
- <DataGridTextColumn
- Binding="{Binding Path=Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
- Header="Имя"/>
- <DataGridTextColumn
- Binding="{Binding Path=Patronymic,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
- Header="Отчество"/>
- <DataGridComboBoxColumn
- ItemsSource="{Binding DataContext.AllTitles,Source={x:Reference ProxyElement}}"
- DisplayMemberPath="Name"
- SelectedValueBinding="{Binding Path=TitleId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- SelectedValuePath="Id"
- Header="Должность"/>
- <DataGridTemplateColumn
- CellTemplate="{StaticResource RegularDateTemplate}"
- CellEditingTemplate="{StaticResource EditingDateTemplate}"
- Header="Дата рождения" />
- <DataGridTextColumn
- Binding="{Binding Path=Phone,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
- Header="Телефон" />
- <DataGridTextColumn
- EditingElementStyle="{StaticResource ValidationFail}"
- Header="Электронная почта">
- <DataGridTextColumn.Binding>
- <Binding
- Path="Email"
- Mode="TwoWay"
- UpdateSourceTrigger="PropertyChanged"
- ValidatesOnExceptions="True">
- <Binding.ValidationRules>
- <validation:Email/>
- </Binding.ValidationRules>
- </Binding>
- </DataGridTextColumn.Binding>
- </DataGridTextColumn>
- </DataGrid.Columns>
- </DataGrid>
- <!--/Сетка редактирования-->
- </StackPanel>
- <!--/Main-->
- </StackPanel>
- </Page>
|