wpf devexpress gricontrol的应用xaml demo

有一些是自己工作中的业务代码,这里只是做一个记录,防止忘记一些自己踩过的坑。主要是如何添加新行,如何控制cell中textedit的编辑状态等。

<editorView:InoEditorView
    x:Class="FA.Platform.Business.ProjectAuthority.Views.UsersAndRolesCtrl"
    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:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxci="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:editorView="clr-namespace:FA.Platform.DataModel.Business;assembly=FA.Platform.DataModel.Business"
    xmlns:fa="https://www.inovance.com/fa"
    xmlns:local="clr-namespace:FA.Platform.Business.ProjectAuthority.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:templateselector="clr-namespace:FA.Platform.Business.ProjectAuthority.TemplateSelector"
    xmlns:theme="clr-namespace:FA.Platform.Internal.UIStyles.ThemeColor;assembly=FA.Platform.Internal.UIStyles"
    xmlns:tips="clr-namespace:FA.Platform.UIControls.Tips.Service;assembly=FA.Platform.UIControls"
    xmlns:xc="clr-namespace:FA.Platform.Business.ProjectAuthority.Common"
    d:DesignHeight="448"
    d:DesignWidth="761"
    mc:Ignorable="d">
    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FA.Platform.Internal.UIStyles;component/Resource/ControlStyle.xaml" />
                <ResourceDictionary Source="pack://application:,,,/FA.Platform.Internal.UIStyles;component/Resource/ButtonStyle.xaml" />
                <ResourceDictionary Source="../Resources/AuthorityControlStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <templateselector:AddUserCellTemplateSelector x:Key="AddUserdt" />
            <templateselector:AddRoleCellTemplateSelector x:Key="AddRoledt" />

            <Style x:Key="UIShape.Up" TargetType="{x:Type Path}">
                <Setter Property="Data" Value="F1 M 4,0 8,4 0,4 4,0 Z " />
                <Setter Property="Fill" Value="Black" />
                <Setter Property="Height" Value="6" />
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="Margin" Value="0,0,0,1" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="Stretch" Value="Fill" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="Width" Value="4" />
            </Style>
            <Style x:Key="UIShape.Down" TargetType="{x:Type Path}">
                <Setter Property="Data" Value="F1 M 0,0 8,0 4,4 0,0 Z " />
                <Setter Property="Fill" Value="Black" />
                <Setter Property="Height" Value="6" />
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="Margin" Value="0,1,0,0" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="Stretch" Value="Fill" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="Width" Value="4" />
            </Style>
            <Style x:Key="GridSplitterStyle" TargetType="{x:Type GridSplitter}">
                <Setter Property="Background" Value="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=BtnGridSplitter_Background}}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GridSplitter}">
                            <Border
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="36" />
                                        <ColumnDefinition Width="4" />
                                        <ColumnDefinition Width="36" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Border
                                        Grid.Column="1"
                                        Height="8"
                                        Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=BtnGridSplitter_BtnBackground}}">
                                        <Path
                                            Width="6"
                                            Height="4"
                                            Margin="15,2,15,2"
                                            HorizontalAlignment="Stretch"
                                            VerticalAlignment="Stretch"
                                            Fill="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Foreground}}"
                                            Style="{StaticResource UIShape.Down}" />
                                    </Border>
                                    <Border
                                        Grid.Column="3"
                                        Height="8"
                                        Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=BtnGridSplitter_BtnBackground}}">
                                        <Path
                                            Width="6"
                                            Height="4"
                                            Margin="15,2,15,2"
                                            HorizontalAlignment="Stretch"
                                            VerticalAlignment="Stretch"
                                            Fill="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Foreground}}"
                                            Style="{StaticResource UIShape.Up}" />
                                    </Border>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <DataTemplate x:Key="pwdCmb">
                <Grid>
                    <ComboBox
                        x:Name="cmb"
                        Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_TableBackground}}"
                        BorderThickness="0"
                        IsDropDownOpen="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.CmbDropDownOpen, Mode=OneWayToSource}"
                        IsEditable="False"
                        IsReadOnly="False">
                        <ComboBoxItem Width="294">
                            <ComboBoxItem.Template>
                                <ControlTemplate>
                                    <Grid Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="17" />
                                            <RowDefinition Height="20" />
                                            <RowDefinition Height="4" />
                                            <RowDefinition Height="20" />
                                            <RowDefinition Height="16" />
                                            <RowDefinition Height="46*" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="76" />
                                            <ColumnDefinition Width="88" />
                                            <ColumnDefinition Width="56" />
                                            <ColumnDefinition Width="8" />
                                            <ColumnDefinition Width="56" />
                                            <ColumnDefinition Width="9*" />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock
                                            Grid.Row="1"
                                            Grid.Column="0"
                                            HorizontalAlignment="Right"
                                            Text="密码:" />
                                        <TextBlock
                                            Grid.Row="3"
                                            Grid.Column="0"
                                            HorizontalAlignment="Right"
                                            Text="确认密码:" />
                                        <PasswordBox
                                            Grid.Row="1"
                                            Grid.Column="1"
                                            Grid.ColumnSpan="4"
                                            Margin="0,0,8,0"
                                            xc:PasswordHelper.Attach="True"
                                            xc:PasswordHelper.Password="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.CurrentNewPwd, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                            BorderThickness="1"
                                            PasswordChar="*">
                                            <dxmvvm:Interaction.Behaviors>
                                                <dxmvvm:EventToCommand
                                                    Command="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.CmdInputPasswordChangedCommand}"
                                                    EventName="PasswordChanged"
                                                    PassEventArgsToCommand="True" />
                                            </dxmvvm:Interaction.Behaviors>
                                        </PasswordBox>
                                        <PasswordBox
                                            Grid.Row="3"
                                            Grid.Column="1"
                                            Grid.ColumnSpan="4"
                                            Margin="0,0,8,0"
                                            xc:PasswordHelper.Attach="True"
                                            xc:PasswordHelper.Password="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.ConfirmPwd, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                            BorderThickness="1"
                                            PasswordChar="*">
                                            <dxmvvm:Interaction.Behaviors>
                                                <dxmvvm:EventToCommand
                                                    Command="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.CmdInputPasswordChangedCommand}"
                                                    EventName="PasswordChanged"
                                                    PassEventArgsToCommand="True" />
                                            </dxmvvm:Interaction.Behaviors>
                                        </PasswordBox>

                                        <Label
                                            Grid.Row="4"
                                            Grid.Column="0"
                                            Grid.ColumnSpan="6"
                                            Height="1"
                                            Margin="8,0,9,0"
                                            VerticalAlignment="Bottom"
                                            Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_BorderBrush}}" />
                                        <Button
                                            Grid.Row="5"
                                            Grid.Column="2"
                                            Margin="0,9,0,9"
                                            Content="确认"
                                            IsEnabled="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.EnableBtn, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                            Style="{StaticResource ButtonBlueBgStyle}"
                                            Tag="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}, Mode=FindAncestor}}">
                                            <dxmvvm:Interaction.Behaviors>
                                                <dxmvvm:EventToCommand
                                                    Command="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.EnsurePasswordCommand}"
                                                    EventName="Click"
                                                    PassEventArgsToCommand="True" />
                                            </dxmvvm:Interaction.Behaviors>
                                        </Button>
                                        <Button
                                            Grid.Row="5"
                                            Grid.Column="4"
                                            Margin="0,9,0,9"
                                            Content="取消"
                                            Style="{StaticResource ButtonWhiteBgStyle}"
                                            Tag="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}, Mode=FindAncestor}}">
                                            <dxmvvm:Interaction.Behaviors>
                                                <dxmvvm:EventToCommand
                                                    Command="{Binding RelativeSource={RelativeSource AncestorType=editorView:InoEditorView}, Path=DataContext.CancelPasswordCommand}"
                                                    EventName="Click"
                                                    PassEventArgsToCommand="True" />
                                            </dxmvvm:Interaction.Behaviors>
                                        </Button>
                                    </Grid>
                                </ControlTemplate>
                            </ComboBoxItem.Template>
                        </ComboBoxItem>
                    </ComboBox>
                    <TextBlock
                        Width="130"
                        HorizontalAlignment="Left"
                        Background="Transparent"
                        Text="{Binding Row.ShowPassword, Mode=TwoWay}" />
                </Grid>
            </DataTemplate>

            <DataTemplate x:Key="NullUserName">
                <TextBlock Name="PART_Editor" Text="&lt;新增用户&gt;" />
            </DataTemplate>
            <DataTemplate x:Key="UserName">
                <dxe:TextEdit Name="PART_Editor" Text="{Binding Row.UserName, Mode=TwoWay}">
                    <dxmvvm:Interaction.Behaviors>
                        <dxmvvm:EventToCommand
                            Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type editorView:InoEditorView}, Mode=FindAncestor}, Path=DataContext.CmbTextChangedCommand}"
                            EventName="EditValueChanged"
                            PassEventArgsToCommand="True" />

                    </dxmvvm:Interaction.Behaviors>
                </dxe:TextEdit>
            </DataTemplate>
            <DataTemplate x:Key="NullPwdCmb">
                <TextBlock Name="PART_Editor" />
            </DataTemplate>
            <DataTemplate x:Key="NUllComment">
                <TextBlock Name="PART_Editor" />
            </DataTemplate>
            <DataTemplate x:Key="Comment">
                <dxe:TextEdit Name="PART_Editor" Text="{Binding Row.Remark, Mode=TwoWay}">
                    <dxmvvm:Interaction.Behaviors>
                        <dxmvvm:EventToCommand
                            Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type editorView:InoEditorView}, Mode=FindAncestor}, Path=DataContext.CmbRemarkChangedCommand}"
                            EventName="EditValueChanged"
                            PassEventArgsToCommand="True" />

                    </dxmvvm:Interaction.Behaviors>
                </dxe:TextEdit>
            </DataTemplate>
            <DataTemplate x:Key="NullRoleName">
                <TextBlock Name="PART_Editor" Text="&lt;新增角色&gt;" />
            </DataTemplate>
            <DataTemplate x:Key="RoleName">
                <dxe:TextEdit Name="PART_Editor" Text="{Binding Row.RoleName, Mode=TwoWay}">
                    <dxmvvm:Interaction.Behaviors>
                        <dxmvvm:EventToCommand
                            Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type editorView:InoEditorView}, Mode=FindAncestor}, Path=DataContext.CmbTextChangedCommand}"
                            EventName="EditValueChanged"
                            PassEventArgsToCommand="True" />

                    </dxmvvm:Interaction.Behaviors>
                    <dxe:TextEdit.Style>
                        <Style TargetType="dxe:TextEdit">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Row.IsAdmin, Mode=TwoWay}" Value="True">
                                    <Setter Property="Focusable" Value="False" />
                                    <Setter Property="IsReadOnly" Value="True" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </dxe:TextEdit.Style>
                </dxe:TextEdit>
            </DataTemplate>
            <DataTemplate x:Key="NullRoleDescription">
                <TextBlock Name="PART_Editor" />
            </DataTemplate>
            <DataTemplate x:Key="RoleDescription">
                <dxe:TextEdit Name="PART_Editor" Text="{Binding Row.Description, Mode=TwoWay}" />
            </DataTemplate>
            <DataTemplate x:Key="NullRoleComment">
                <TextBlock Name="PART_Editor" />
            </DataTemplate>
            <DataTemplate x:Key="RoleComment">
                <dxe:TextEdit Name="PART_Editor" Text="{Binding Row.Remark, Mode=TwoWay}">
                    <dxmvvm:Interaction.Behaviors>
                        <dxmvvm:EventToCommand
                            Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type editorView:InoEditorView}, Mode=FindAncestor}, Path=DataContext.CmbTextChangedCommand}"
                            EventName="EditValueChanged"
                            PassEventArgsToCommand="True" />

                    </dxmvvm:Interaction.Behaviors>
                    <dxe:TextEdit.Style>
                        <Style TargetType="dxe:TextEdit">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Row.IsAdmin, Mode=TwoWay}" Value="True">
                                    <Setter Property="Focusable" Value="False" />
                                    <Setter Property="IsReadOnly" Value="True" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </dxe:TextEdit.Style>
                </dxe:TextEdit>
            </DataTemplate>
        </ResourceDictionary>
    </Control.Resources>
    <Grid>
        <dx:DXTabControl Grid.Row="0">
            <dxmvvm:Interaction.Behaviors>
                <dxmvvm:EventToCommand
                    Command="{Binding TabItemChangedCommand}"
                    EventName="SelectionChanged"
                    PassEventArgsToCommand="True" />
            </dxmvvm:Interaction.Behaviors>
            <!--  用户管理界面  -->
            <dx:DXTabItem Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}">
                <dx:DXTabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{fa:SvgImage FA.Platform.Image.User}" />
                        <TextBlock Margin="2" Text="用户" />
                    </StackPanel>
                </dx:DXTabItem.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="175" />
                        <RowDefinition Height="12" />
                        <RowDefinition Height="201*" />
                    </Grid.RowDefinitions>
                    <Grid Grid.Row="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="24" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="0" Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="28" />
                                <ColumnDefinition Width="28" />
                                <ColumnDefinition />
                                <ColumnDefinition Width="28" />
                            </Grid.ColumnDefinitions>
                            <dx:DXImage
                                Grid.Column="0"
                                Margin="4"
                                Source="{fa:SvgImage FA.Platform.Image.RolesRefresh}" />
                            <dx:DXImage
                                Grid.Column="1"
                                Margin="4"
                                Source="{fa:SvgImage FA.Platform.Image.UserRefresh}" />
                            <dx:DXImage
                                Grid.Column="3"
                                Margin="4"
                                Source="{fa:SvgImage FA.Platform.Image.UserWindow}" />
                        </Grid>
                        <Border
                            Grid.Row="1"
                            Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}"
                            BorderBrush="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_BorderBrush}}"
                            BorderThickness="0,1,0,0">
                            <TextBlock
                                Margin="6,0,0,0"
                                VerticalAlignment="Center"
                                Text="用户" />
                        </Border>
                        <dxg:GridControl
                            Grid.Row="2"
                            ItemsSource="{Binding UserCollection, Mode=TwoWay}"
                            SelectedItem="{Binding IsSelectedUserItem, Mode=TwoWay}"
                            SelectedItems="{Binding SelectedUserItemsCollection, Mode=TwoWay}"
                            SelectionMode="Row">
                            <dxg:GridControl.View>
                                <dxg:TableView
                                    VerticalAlignment="Top"
                                    AutoWidth="True"
                                    EditorShowMode="MouseUpFocused"
                                    NewItemRowPosition="Bottom"
                                    ShowGroupPanel="False"
                                    ShowHorizontalLines="True"
                                    ShowIndicator="False"
                                    ShowVerticalLines="True"
                                    VerticalScrollbarVisibility="Auto">
                                    <dxg:TableView.RowStyle>
                                        <Style TargetType="dxg:RowControl">
                                            <Setter Property="dxg:ToolTipHelper.ShowTooltip" Value="False" />
                                        </Style>
                                    </dxg:TableView.RowStyle>
                                    <dxmvvm:Interaction.Behaviors>
                                        <dxmvvm:EventToCommand
                                            Command="{Binding DoubleClickUserCommand}"
                                            EventName="RowDoubleClick"
                                            PassEventArgsToCommand="True" />
                                        <dxmvvm:EventToCommand
                                            Command="{Binding UserRowRightClickCommand}"
                                            EventName="MouseRightButtonDown"
                                            PassEventArgsToCommand="True" />
                                    </dxmvvm:Interaction.Behaviors>
                                </dxg:TableView>
                            </dxg:GridControl.View>
                            <dxg:GridControl.Columns>
                                <dxg:GridColumn
                                    Width="16"
                                    MaxWidth="16"
                                    AllowResizing="false"
                                    FixedWidth="True">
                                    <dxg:GridColumn.CellTemplate>
                                        <DataTemplate>
                                            <dx:DXImage
                                                Width="16"
                                                Height="16"
                                                VerticalAlignment="Center"
                                                dx:SvgImageHelper.State="{Binding Path=(dx:ThemeManager.TreeWalker).ThemeName, RelativeSource={RelativeSource Self}}"
                                                Source="{Binding Data.UserImage}">
                                                <dx:WpfSvgPalette.Palette>
                                                    <dx:WpfSvgPalette>
                                                        <dx:WpfSvgPalette.States>
                                                            <dx:WpfSvgPalette x:Key="FALight">
                                                                <SolidColorBrush x:Key="Black" Color="Black" />
                                                            </dx:WpfSvgPalette>
                                                            <dx:WpfSvgPalette x:Key="FADark">
                                                                <SolidColorBrush x:Key="black" Color="White" />
                                                            </dx:WpfSvgPalette>
                                                        </dx:WpfSvgPalette.States>
                                                    </dx:WpfSvgPalette>
                                                </dx:WpfSvgPalette.Palette>
                                            </dx:DXImage>
                                        </DataTemplate>
                                    </dxg:GridColumn.CellTemplate>
                                </dxg:GridColumn>
                                <dxg:GridColumn
                                    Width="279"
                                    MaxWidth="279"
                                    AllowFocus="True"
                                    AllowResizing="false"
                                    CellTemplateSelector="{StaticResource AddUserdt}"
                                    FieldName="UserName"
                                    FixedWidth="True"
                                    Header="用户名" />
                                <dxg:GridColumn
                                    Width="160"
                                    MaxWidth="160"
                                    AllowResizing="false"
                                    CellTemplateSelector="{StaticResource AddUserdt}"
                                    FieldName="ShowPassword"
                                    FixedWidth="True"
                                    Header="密码" />
                                <dxg:GridColumn
                                    Width="160"
                                    MaxWidth="160"
                                    AllowResizing="false"
                                    CellTemplateSelector="{StaticResource AddUserdt}"
                                    FieldName="Remark"
                                    FixedWidth="True"
                                    Header="注释" />
                            </dxg:GridControl.Columns>
                        </dxg:GridControl>
                    </Grid>
                    <GridSplitter
                        Grid.Row="1"
                        HorizontalAlignment="Stretch"
                        Style="{StaticResource GridSplitterStyle}" />
                    <!--  为用户分配角色界面  -->
                    <dx:DXTabControl Grid.Row="2">
                        <dx:DXTabItem Header="分配的角色">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="24" />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Border
                                    Grid.Row="0"
                                    Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}"
                                    BorderBrush="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_BorderBrush}}"
                                    BorderThickness="0,0,0,0">
                                    <TextBlock
                                        Margin="6,0,0,0"
                                        VerticalAlignment="Center"
                                        Text="分配的角色" />
                                </Border>
                                <dxg:GridControl Grid.Row="1" ItemsSource="{Binding UserRolesCollection, Mode=TwoWay}">
                                    <dxg:GridControl.View>
                                        <dxg:TableView
                                            MaxHeight="1000"
                                            VerticalAlignment="Top"
                                            AutoWidth="True"
                                            ShowGroupPanel="False"
                                            ShowHorizontalLines="True"
                                            ShowIndicator="False"
                                            ShowVerticalLines="True"
                                            VerticalScrollbarVisibility="Auto" />
                                    </dxg:GridControl.View>
                                    <dxg:GridControl.Columns>
                                        <dxg:GridColumn Width="16" FixedWidth="True">
                                            <dxg:GridColumn.CellTemplate>
                                                <DataTemplate>
                                                    <dx:DXImage
                                                        Width="16"
                                                        Height="16"
                                                        VerticalAlignment="Center"
                                                        dx:SvgImageHelper.State="{Binding Path=(dx:ThemeManager.TreeWalker).ThemeName, RelativeSource={RelativeSource Self}}"
                                                        Source="{Binding Data.RoleImage}">
                                                        <dx:WpfSvgPalette.Palette>
                                                            <dx:WpfSvgPalette>
                                                                <dx:WpfSvgPalette.States>
                                                                    <dx:WpfSvgPalette x:Key="FALight">
                                                                        <SolidColorBrush x:Key="Black" Color="Black" />
                                                                    </dx:WpfSvgPalette>
                                                                    <dx:WpfSvgPalette x:Key="FADark">
                                                                        <SolidColorBrush x:Key="black" Color="White" />
                                                                    </dx:WpfSvgPalette>
                                                                </dx:WpfSvgPalette.States>
                                                            </dx:WpfSvgPalette>
                                                        </dx:WpfSvgPalette.Palette>
                                                    </dx:DXImage>
                                                </DataTemplate>
                                            </dxg:GridColumn.CellTemplate>
                                        </dxg:GridColumn>
                                        <dxg:GridColumn Header="分配给" ReadOnly="False">
                                            <dxg:GridColumn.CellTemplate>
                                                <DataTemplate>
                                                    <CheckBox HorizontalAlignment="Left" IsChecked="{Binding Row.IsChecked, Mode=TwoWay}" />
                                                </DataTemplate>
                                            </dxg:GridColumn.CellTemplate>
                                        </dxg:GridColumn>
                                        <dxg:GridColumn
                                            FieldName="RoleName"
                                            Header="名称"
                                            ReadOnly="True" />
                                        <dxg:GridColumn
                                            FieldName="Description"
                                            Header="描述"
                                            ReadOnly="True" />
                                        <dxg:GridColumn
                                            FieldName="Remark"
                                            Header="注释"
                                            ReadOnly="True" />
                                    </dxg:GridControl.Columns>
                                </dxg:GridControl>
                            </Grid>
                        </dx:DXTabItem>
                    </dx:DXTabControl>
                </Grid>
            </dx:DXTabItem>
            <!--  角色管理界面  -->
            <dx:DXTabItem Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}">
                <dx:DXTabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{fa:SvgImage FA.Platform.Image.Roles}" />
                        <TextBlock Margin="2" Text="角色" />
                    </StackPanel>
                </dx:DXTabItem.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="175" />
                        <RowDefinition Height="12" />
                        <RowDefinition Height="201*" />
                    </Grid.RowDefinitions>
                    <Grid Grid.Row="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="24" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="0" Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="28" />
                                <ColumnDefinition Width="28" />
                                <ColumnDefinition />
                                <ColumnDefinition Width="28" />
                            </Grid.ColumnDefinitions>
                            <dx:DXImage
                                Grid.Column="0"
                                Margin="4"
                                Source="{fa:SvgImage FA.Platform.Image.RolesRefresh}" />
                            <dx:DXImage
                                Grid.Column="1"
                                Margin="4"
                                Source="{fa:SvgImage FA.Platform.Image.UserRefresh}" />
                            <dx:DXImage
                                Grid.Column="3"
                                Margin="4"
                                Source="{fa:SvgImage FA.Platform.Image.UserWindow}" />
                        </Grid>
                        <Border
                            Grid.Row="1"
                            Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}"
                            BorderBrush="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_BorderBrush}}"
                            BorderThickness="0,1,0,0">
                            <TextBlock
                                Margin="6,0,0,0"
                                VerticalAlignment="Center"
                                Text="角色" />
                        </Border>
                        <dxg:GridControl
                            Grid.Row="2"
                            ItemsSource="{Binding RolesCollection, Mode=TwoWay}"
                            SelectedItem="{Binding IsSelectedRoleItem, Mode=TwoWay}"
                            SelectedItems="{Binding SelectedRoleItemsCollection, Mode=TwoWay}"
                            SelectionMode="Row">
                            <dxg:GridControl.View>
                                <dxg:TableView
                                    VerticalAlignment="Top"
                                    AutoWidth="True"
                                    EditorShowMode="MouseDownFocused"
                                    NewItemRowPosition="Bottom"
                                    ShowGroupPanel="False"
                                    ShowHorizontalLines="True"
                                    ShowIndicator="False"
                                    ShowVerticalLines="True"
                                    VerticalScrollbarVisibility="Auto">
                                    <dxmvvm:Interaction.Behaviors>
                                        <dxmvvm:EventToCommand
                                            Command="{Binding DoubleClickRoleCommand}"
                                            EventName="RowDoubleClick"
                                            PassEventArgsToCommand="True" />
                                        <dxmvvm:EventToCommand
                                            Command="{Binding RoleRowRightClickCommand}"
                                            EventName="MouseRightButtonDown"
                                            PassEventArgsToCommand="True" />
                                    </dxmvvm:Interaction.Behaviors>
                                    <dxg:TableView.InputBindings>
                                        <KeyBinding Command="{Binding RemoveRoleRowsCommand}" Gesture="enter" />
                                    </dxg:TableView.InputBindings>
                                </dxg:TableView>
                            </dxg:GridControl.View>
                            <dxg:GridControl.Columns>
                                <dxg:GridColumn Width="16" FixedWidth="True">
                                    <dxg:GridColumn.CellTemplate>
                                        <DataTemplate>
                                            <dx:DXImage
                                                Width="16"
                                                Height="16"
                                                VerticalAlignment="Center"
                                                dx:SvgImageHelper.State="{Binding Path=(dx:ThemeManager.TreeWalker).ThemeName, RelativeSource={RelativeSource Self}}"
                                                Source="{Binding Data.RoleImage}">
                                                <dx:WpfSvgPalette.Palette>
                                                    <dx:WpfSvgPalette>
                                                        <dx:WpfSvgPalette.States>
                                                            <dx:WpfSvgPalette x:Key="FALight">
                                                                <SolidColorBrush x:Key="Black" Color="Black" />
                                                            </dx:WpfSvgPalette>
                                                            <dx:WpfSvgPalette x:Key="FADark">
                                                                <SolidColorBrush x:Key="black" Color="White" />
                                                            </dx:WpfSvgPalette>
                                                        </dx:WpfSvgPalette.States>
                                                    </dx:WpfSvgPalette>
                                                </dx:WpfSvgPalette.Palette>
                                            </dx:DXImage>
                                        </DataTemplate>
                                    </dxg:GridColumn.CellTemplate>
                                </dxg:GridColumn>
                                <dxg:GridColumn
                                    CellTemplateSelector="{StaticResource AddRoledt}"
                                    FieldName="RoleName"
                                    Header="名称">
                                    <!--<dxg:GridColumn.Style>
                                        <Style TargetType="dxg:GridColumn">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding row.RoleName}" Value="管理员">
                                                    <Setter Property="ReadOnly" Value="True" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </dxg:GridColumn.Style>-->

                                </dxg:GridColumn>
                                <dxg:GridColumn
                                    CellTemplateSelector="{StaticResource AddRoledt}"
                                    FieldName="Description"
                                    Header="描述"
                                    ReadOnly="True" />
                                <dxg:GridColumn
                                    CellTemplateSelector="{StaticResource AddRoledt}"
                                    FieldName="Remark"
                                    Header="注释" />
                            </dxg:GridControl.Columns>
                        </dxg:GridControl>
                    </Grid>
                    <GridSplitter
                        Grid.Row="1"
                        HorizontalAlignment="Stretch"
                        Style="{StaticResource GridSplitterStyle}" />
                    <!--  为角色分配权限  -->
                    <dx:DXTabControl Grid.Row="2">
                        <dx:DXTabItem Header="权限">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="24" />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Border
                                    Grid.Row="0"
                                    Background="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_Background}}"
                                    BorderBrush="{dxci:ThemeResource {theme:ThemeResourcesThemeKey ResourceKey=Standard_BorderBrush}}"
                                    BorderThickness="0,0,0,0">
                                    <TextBlock
                                        Margin="6,0,0,0"
                                        VerticalAlignment="Center"
                                        Text="分配权限" />
                                </Border>
                                <dxg:GridControl Grid.Row="1" ItemsSource="{Binding RoleAuthsCollection, Mode=TwoWay}">
                                    <dxg:GridControl.View>
                                        <dxg:TableView
                                            MaxHeight="1000"
                                            VerticalAlignment="Top"
                                            AutoWidth="True"
                                            ShowGroupPanel="False"
                                            ShowHorizontalLines="True"
                                            ShowIndicator="False"
                                            ShowVerticalLines="True"
                                            VerticalScrollbarVisibility="Auto" />
                                    </dxg:GridControl.View>
                                    <dxg:GridControl.Columns>
                                        <dxg:GridColumn
                                            Width="50"
                                            FieldName="{x:Null}"
                                            ReadOnly="False">
                                            <dxg:GridColumn.CellTemplate>
                                                <DataTemplate>
                                                    <CheckBox IsChecked="{Binding Row.IsChecked, Mode=TwoWay}" />
                                                </DataTemplate>
                                            </dxg:GridColumn.CellTemplate>
                                        </dxg:GridColumn>
                                        <dxg:GridColumn FieldName="名称" ReadOnly="True">
                                            <dxg:GridColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Row.Name}" />
                                                </DataTemplate>
                                            </dxg:GridColumn.CellTemplate>
                                        </dxg:GridColumn>
                                        <dxg:GridColumn FieldName="注释" ReadOnly="True">
                                            <dxg:GridColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Row.Remark}" />
                                                </DataTemplate>
                                            </dxg:GridColumn.CellTemplate>
                                        </dxg:GridColumn>
                                    </dxg:GridControl.Columns>
                                </dxg:GridControl>
                            </Grid>
                        </dx:DXTabItem>
                    </dx:DXTabControl>
                </Grid>
            </dx:DXTabItem>
        </dx:DXTabControl>
    </Grid>
</editorView:InoEditorView>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值