|
- <UserControl x:Class="BPASmartClient.CustomResource.Pages.View.UserManagerView"
- 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:BPASmartClient.CustomResource.Pages.View"
- xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel"
- Width="1400"
- Height="900"
- Background="{x:Null}"
- mc:Ignorable="d">
- <UserControl.DataContext>
- <vm:UserManagerViewModel/>
- </UserControl.DataContext>
- <UserControl.Resources>
- <Style x:Key="CommonTextBlockStyle" TargetType="TextBlock">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="Foreground" Value="#B1E8FF"/>
- <Setter Property="HorizontalAlignment" Value="Center"/>
- <Setter Property="VerticalAlignment" Value="Center"/>
- </Style>
- <Style TargetType="{x:Type DataGridCell}">
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="TextBlock.FontSize" Value="13" />
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="BorderBrush" Value="#87CEFA"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content.Text}" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type DataGridCell}">
- <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
- <!--HorizontalAlignment 可以设置内容展示位置-->
- <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" HorizontalAlignment="Center"
- Margin="{TemplateBinding Padding}"/>
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Opacity" Value=".56"/>
- </Trigger>
- </Style.Triggers>
- </Style>
- <Style TargetType="DataGridRow">
- <Setter Property="FontSize" Value="16"/>
- <Setter Property="VerticalAlignment" Value="Center"/>
- <Setter Property="Margin" Value="0,5"/>
- <Style.Triggers>
- <!-- 隔行换色 -->
- <Trigger Property="AlternationIndex" Value="0">
- <Setter Property="Background" Value="Transparent" />
- </Trigger>
- <Trigger Property="AlternationIndex" Value="1">
- <Setter Property="Background" Value="Transparent" />
- </Trigger>
-
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" Value="#87CEFA" />
- </Trigger>
- </Style.Triggers>
- </Style>
- <Style TargetType="DataGridColumnHeader">
- <Setter Property="SnapsToDevicePixels" Value="True" />
- <Setter Property="MinWidth" Value="0" />
- <Setter Property="MinHeight" Value="40" />
- <Setter Property="Foreground" Value="#ddd" />
- <Setter Property="FontSize" Value="26" />
- <Setter Property="Cursor" Value="Hand" />
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="DataGridColumnHeader">
-
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <ContentPresenter Margin="0,0,0,0" VerticalAlignment="Center"
- HorizontalAlignment="Center" />
- <Path x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill"
- Grid.Column="0" Width="8" Height="6" Fill="Transparent" Margin="0,0,50,0"
- VerticalAlignment="Center" RenderTransformOrigin="1,1" />
- <Rectangle Width="1" Fill="#87CEFA" HorizontalAlignment="Right" Grid.ColumnSpan="1" />
- </Grid>
-
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Setter Property="Height" Value="25" />
- </Style>
- <Style x:Key="datagridButton" TargetType="Button">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="BorderBrush" Value="Transparent"/>
- <Setter Property="Foreground" Value="#1874CD"/>
- <Setter Property="FontSize" Value="18"/>
- </Style>
- </UserControl.Resources>
- <Grid>
- <Grid.ColumnDefinitions>
-
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="50"/>
- <RowDefinition Height="*"/>
- <RowDefinition Height="100"/>
- </Grid.RowDefinitions>
- <TextBlock Text="用户管理" FontSize="28" Style="{DynamicResource CommonTextBlockStyle}"/>
- <DataGrid Grid.Row="1" Margin="30" AutoGenerateColumns="False" RowHeight="35" ItemsSource="{Binding userManager}"
- Background="Transparent"
- FrozenColumnCount="1"
- VerticalAlignment="Top"
- IsReadOnly="True"
- CanUserResizeColumns="False" CanUserResizeRows="False" SelectionMode="Single"
- CanUserReorderColumns="False" AlternationCount="2" RowHeaderWidth="0" CanUserAddRows="False">
- <DataGrid.Columns>
- <DataGridTemplateColumn Header="用户名" Width="200">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding UserName}" FontSize="20" Foreground="White"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="最后登录时间" Width="300" >
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding LastLogInTime}" FontSize="20" Foreground="White"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="权限" Width="250">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <Button Content="权限" Style="{DynamicResource datagridButton}"
- Command="{Binding DataContext.EditUserConfigCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
- CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid},Path=SelectedItem}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="重置密码" Width="250">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <Button Content="重置密码" Style="{DynamicResource datagridButton}" Command="{Binding DataContext.ChangePasswardCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
- CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid},Path=SelectedItem}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="删除" Width="*">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <Button Content="删除" Style="{DynamicResource datagridButton}"
- Command="{Binding DataContext.DeleteUserCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
- CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid},Path=SelectedItem}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- </DataGrid.Columns>
-
- </DataGrid>
- <Button Grid.Row="2"
- Height="50" Width="200"
- Background="#009DFF"
- BorderThickness="0"
- Command="{Binding AddNewUserCommand}"
- Content="添加新用户"
- FontSize="24"
- Foreground="White" />
- </Grid>
- </UserControl>
|