Explorar o código

添加菜单管理

ltwork hai 1 ano
pai
achega
75f6ba4992

+ 2 - 0
BlankApp1/BlankApp1/App.xaml.cs

@@ -102,6 +102,8 @@ namespace BlankApp1
             containerRegistry.RegisterDialog<AddEditRoleView, AddEditRoleViewModel>();
             containerRegistry.RegisterDialog<RoleWithMenuView, RoleWithMenuViewModel>();
             containerRegistry.RegisterDialog<RoleWithProjectView, RoleWithProjectViewModel>();
+            containerRegistry.RegisterDialog<AddEditMenuView, AddEditMenuViewModel>();
+            
         }
 
         private IMapper GetMapper(IContainerProvider container)

BIN=BIN
BlankApp1/BlankApp1/Assets/Images/login.png


+ 3 - 1
BlankApp1/BlankApp1/PLCTool.csproj

@@ -49,7 +49,9 @@
     <Resource Include="Assets\Fonts\iconfont.ttf">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>
-    <Resource Include="Assets\Images\login.png" />
+    <Resource Include="Assets\Images\login.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Resource>
     <Resource Include="Assets\Images\Logo.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>

+ 281 - 0
BlankApp1/BlankApp1/ViewModels/SystemManageViewModel/Dialogs/AddEditMenuViewModel.cs

@@ -0,0 +1,281 @@
+using AutoMapper;
+using BizService;
+using Model.Dto;
+using Model.Entities;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PLCTool.ViewModels.SystemManageViewModel.Dialogs
+{
+ 
+    public class AddEditMenuViewModel : BindableBase, IDialogAware
+    {
+        private readonly IEventAggregator _aggregator;
+  
+        private readonly IMenuService _iMenuService;
+        private readonly IMapper _mapper;
+        private List<MenuDto> allMenuInfoList = new List<MenuDto>();
+        
+
+        private int id = 0;
+        public AddEditMenuViewModel(IEventAggregator aggregator, IMenuService iMenuService, IMapper mapper)
+        {
+            _aggregator = aggregator;
+            
+            _iMenuService = iMenuService;
+            _mapper = mapper;
+            CloseCommand = new DelegateCommand(Close);
+            SureCommand = new DelegateCommand<string>(Sure);
+            CancelCommand = new DelegateCommand(Close);
+
+            GetMenus();
+          
+
+        }
+
+
+
+
+        #region idialog接口实现
+        public string Title { set; get; } = "新增用户";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            var getMsg = parameters.GetValues<int>("Key");
+            ///值不为空,表示修改
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg)
+                {
+                    if (item != null)
+                    {
+                        Title = "修改菜单";
+                        id = item;
+                        var findMenu = allMenuInfoList.FirstOrDefault(x => x.MenuId == id);
+                        if (findMenu != null)
+                        {
+                            MenuHeader = findMenu.MenuHeader;
+                            TargetView = findMenu.TargetView;
+                            ParentId = findMenu.ParentId;
+                            MenuIcon = findMenu.MenuIcon;
+                            Index = findMenu.Index;
+                        }
+                        
+                    }
+
+                }
+
+            }
+        }
+
+        #endregion
+        #region 私有方法
+
+
+        /// <summary>
+        /// 判断输入的数据
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+
+
+        private void Close()
+        {
+            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+        /// <summary>
+        /// 确认
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Sure(string obj)
+        {
+            if (string.IsNullOrEmpty(MenuHeader))
+            {
+                MessageBox.Show("请填写菜单名", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+            if (string.IsNullOrEmpty(TargetView))
+            {
+                MessageBox.Show("请填写菜单界面!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+            if (string.IsNullOrEmpty(MenuIcon))
+            {
+                MessageBox.Show("请选择图标!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+          
+            //判断是否存在用户名
+
+            var findResult = allMenuInfoList.FirstOrDefault(x => x.MenuHeader == MenuHeader);
+            if (findResult != null)
+            {
+                if (Title == "新增用户")
+                {
+                    MessageBox.Show("已存在此菜单名!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                    return;
+                }
+                else
+                {
+                    //修改时,若查到其他的用户名和这个重复
+                    if (findResult.MenuId != id)
+                    {
+                        MessageBox.Show("已存在此菜单名!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                        return;
+                    }
+                }
+            }
+
+
+            if (Title == "新增用户")
+            {
+                AddUser();
+            }
+            else
+            {
+                EditUser();
+
+            }
+
+            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+        }
+
+        private void AddUser()
+        {
+
+            ////添加到数据库user表中
+            //iMenuService.Add(new User()
+            //{
+            //    UserName = UserName,
+            //    Password = PassWord,
+            //    Description = Describe
+            //});
+            ////查找添加的userid
+            //int newUserId = 0;
+            //var findId = _iUserService.QueryList().FirstOrDefault(x => x.UserName == UserName);
+            //if (findId != null)
+            //{
+            //    newUserId = findId.Id;
+            //}
+            ////添加到数据库useRole表中
+            //bool isAdd = _iMenuService.Add(new UserRole()
+            //{
+            //    UserId = newUserId,
+            //    RoleId = allRoles.FirstOrDefault(x => x.Name == (SelectRole)).Id
+            //});
+            //if (isAdd)
+            //{
+            //    MessageBox.Show("添加用户成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+
+            //}
+
+        }
+        private void EditUser()
+        {
+            Menu menu = new Menu()
+            {
+                
+                MenuHeader = MenuHeader,
+                TargetView = TargetView,
+                ParentId = ParentId,
+                MenuIcon= MenuIcon,
+                Index=Index
+
+            };
+            //修改到数据库user表中
+            bool isedit = _iMenuService.Edit(menu);
+            if (isedit)
+            {
+                MessageBox.Show("修改用户成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+
+            }
+           
+
+
+        }
+   
+
+        private void GetMenus()
+        {
+            var menus = _iMenuService.QueryList();
+            allMenuInfoList = _mapper.Map<List<Menu>, List<MenuDto>>(menus);
+        }
+        #endregion
+
+
+
+        #region 命令绑定
+        public DelegateCommand CloseCommand { set; get; }
+        public DelegateCommand<string> SureCommand { set; get; }
+        public DelegateCommand CancelCommand { set; get; }
+
+
+
+        #endregion
+        #region 变量绑定
+        private string menuHeader;
+        public string MenuHeader
+        {
+            get { return menuHeader; }
+            set { menuHeader = value; RaisePropertyChanged(); }
+        }
+        private string targetView;
+        public string TargetView
+        {
+            get { return targetView; }
+            set { targetView = value; RaisePropertyChanged(); }
+        }
+
+        private int parentId;
+        public int ParentId
+        {
+            get { return parentId; }
+            set { parentId = value; RaisePropertyChanged(); }
+        }
+
+        private string menuIcon;
+        public string MenuIcon
+        {
+            get { return menuIcon; }
+            set { menuIcon = value; RaisePropertyChanged(); }
+        }
+        private int index;
+        public int Index
+        {
+            get { return index; }
+            set { index = value; RaisePropertyChanged(); }
+        }
+        
+     
+
+        private string describe;
+        public string Describe
+        {
+            get { return describe; }
+            set { describe = value; RaisePropertyChanged(); }
+        }
+
+        #endregion
+    }
+}

+ 147 - 2
BlankApp1/BlankApp1/ViewModels/SystemManageViewModel/MenuManageViewModel.cs

@@ -1,12 +1,157 @@
-using System;
+using AutoMapper;
+using BizService;
+using Microsoft.Extensions.Logging;
+using Model.Dto;
+using Model.Entities;
+using PLCTool.Events;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 
 namespace PLCTool.ViewModels.SystemManageViewModel
 {
-    public  class MenuManageViewModel
+    
+    public class MenuManageViewModel : BindableBase
     {
+        private readonly IMenuService _iMenuService;
+        private readonly ILogger _logger;
+        private readonly IMapper _mapper;
+        private readonly IDialogService _dialog;
+        private readonly IEventAggregator _aggregator;
+        private List<MenuDto> allMenuInfoList = new List<MenuDto>();
+        private string basePath=System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images");
+        public MenuManageViewModel(IMenuService iMenuService, IMapper mapper, ILogger logger, IDialogService dialog, EventAggregator aggregator)
+        {
+
+            _iMenuService = iMenuService;
+            _mapper = mapper;
+            _logger = logger;
+            _dialog = dialog;
+            _aggregator = aggregator;
+            AddCommand = new DelegateCommand<object>(AddMenu);
+            EditCommand = new DelegateCommand<object>(EditMenu);
+            DeleteCommand = new DelegateCommand<object>(Delete);
+            OnLoadCommand = new DelegateCommand(OnLoad);
+            QueryCommand = new DelegateCommand<object>(Query);
+        }
+
+
+
+
+        #region 私有方法
+        private void OnLoad()
+        {
+            GetAllMenus();
+        }
+        private void AddMenu(object obj)
+        {
+            _dialog.ShowDialog("AddEditMenuView", async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    GetAllMenus();
+                }
+
+            });
+        }
+
+        private void EditMenu(object obj)
+        {
+            int id = Convert.ToInt32(obj);
+
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", id);
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
+            _dialog.ShowDialog("AddEditMenuView", parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    GetAllMenus();
+                }
+
+            });
+        }
+
+        private void Delete(object obj)
+        {
+            int id = Convert.ToInt32(obj);
+            MessageBoxResult boxResult = MessageBox.Show("确认删除此条数据?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (boxResult == MessageBoxResult.OK)
+            {
+                var del = _iMenuService.Delete(id);
+                if (del)
+                {
+                    MessageBox.Show("删除成功!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                    GetAllMenus();
+                }
+
+            }
+        }
+        private void GetAllMenus()
+        {
+            var menus = _iMenuService.QueryList();
+            allMenuInfoList = _mapper.Map<List<Menu>, List<MenuDto>>(menus);
+            
+            MenuInfoList = new ObservableCollection<MenuDto>(allMenuInfoList);
+        }
+
+        /// <summary>
+        /// 判断输入的数据
+        /// </summary>
+        /// <param name="input"></param>
+
+        /// <summary>
+        /// 获取PLC配置
+        /// </summary>
+
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Query(object obj)
+        {
+            var conMenus = (from a in allMenuInfoList
+                            where (string.IsNullOrEmpty(MenuName) ? true : (a.MenuHeader.Contains(MenuName)))
+
+                            select a).ToList();
+            //默认显示的第一页
+
+            MenuInfoList = new ObservableCollection<MenuDto>(conMenus);
+        }
+
+        #endregion
+        #region 数据绑定
+        private ObservableCollection<MenuDto> menuInfoList = new ObservableCollection<MenuDto>();
+        public ObservableCollection<MenuDto> MenuInfoList
+        {
+            get { return menuInfoList; }
+            set { menuInfoList = value; RaisePropertyChanged(); }
+        }
+        private string menuName = string.Empty;
+        public string MenuName
+        {
+            get { return menuName; }
+            set { menuName = value; RaisePropertyChanged(); }
+        }
+
+        #endregion
+
+        #region 命令绑定
+        public DelegateCommand OnLoadCommand { set; get; }
+        public DelegateCommand<object> AddCommand { set; get; }
+        public DelegateCommand<object> EditCommand { set; get; }
+        public DelegateCommand<object> DeleteCommand { set; get; }
+        public DelegateCommand<object> QueryCommand { set; get; }
+
+        #endregion
     }
 }

+ 5 - 3
BlankApp1/BlankApp1/Views/LoginView.xaml

@@ -27,11 +27,11 @@
         <DockPanel Margin="15" VerticalAlignment="Center" Grid.Column="1" >
             <TextBlock Margin="0,10" DockPanel.Dock="Top" FontSize="22" FontWeight="Bold" Text="欢迎使用" HorizontalAlignment="Center"/>
             <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
-                <TextBlock Margin="0,10" Width="80"  TextAlignment="Right" FontSize="16" FontWeight="Bold" Text="用户名:" />
+                <TextBlock Margin="0,10" Width="80"  TextAlignment="Right" FontSize="16"  Text="用户名:" />
                 <TextBox Margin="0,10" Width="120" Height="25"  Text="{Binding UserName}" Cursor="IBeam" />
             </StackPanel>
             <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
-                <TextBlock Margin="0,10"  Width="80"  TextAlignment="Right"  FontSize="16" FontWeight="Bold" Text="密码:" />
+                <TextBlock Margin="0,10"  Width="80"  TextAlignment="Right"  FontSize="16"  Text="密码:" />
                 <PasswordBox Margin="0,10" Width="120" Height="25" pass:PassWordExtensions.PassWord="{Binding PassWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
         DockPanel.Dock="Top" Cursor="IBeam">
                     <i:Interaction.Behaviors>
@@ -44,7 +44,9 @@
                     </PasswordBox.InputBindings>
                 </PasswordBox>
             </StackPanel>
-            <Button Command="{Binding ExecuteCommand}" CommandParameter="Login" Content="登录系统"  DockPanel.Dock="Top" Style="{StaticResource NormalButtonStyle}"  Cursor="Hand" />
+            <Button Command="{Binding ExecuteCommand}" CommandParameter="Login" Content="登  录"  DockPanel.Dock="Top" Style="{StaticResource NormalButtonStyle}"  Cursor="Hand" />
+            
+            
         </DockPanel>
         <Border BorderBrush="AliceBlue" BorderThickness="0.5" Grid.Column="1"/>
     </Grid>

+ 56 - 0
BlankApp1/BlankApp1/Views/SystemManageView/Dialogs/AddEditMenuView.xaml

@@ -0,0 +1,56 @@
+<UserControl x:Class="PLCTool.Views.SystemManageView.Dialogs.AddEditMenuView"
+             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:local="clr-namespace:PLCTool.Views.SystemManageView.Dialogs"
+                         xmlns:prism="http://prismlibrary.com/"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:pass="clr-namespace:PLCTool.Common.Extension"
+             Height="300" Width="400" BorderBrush="#CBCBCB" BorderThickness="1">
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="20"/>
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+        </Grid.RowDefinitions>
+
+        <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center">
+            <TextBlock Text="菜单名:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
+            <TextBox  Height="28" Width="120" Text="{Binding MenuHeader}" />
+        </StackPanel>
+      
+        <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Center">
+            <TextBlock Text="父Id:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
+            <TextBox  Height="28" Width="120" Text="{Binding ParentId}" />
+        </StackPanel>
+        <StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Center">
+            <TextBlock Text="图标:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
+            <TextBox  Height="28" Width="120" Text="{Binding MenuIcon}" />
+        </StackPanel>
+
+
+        <StackPanel Orientation="Horizontal"  Grid.Row="4" HorizontalAlignment="Center">
+            <TextBlock Text="排序:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
+            <TextBox  Height="28" Width="120" Text="{Binding Index}" />
+        </StackPanel>
+        <StackPanel Orientation="Horizontal" Grid.Row="5" HorizontalAlignment="Center">
+            <TextBlock Text="描述:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80" />
+            <TextBox  Height="28" Width="220" Text="{Binding Describe}" />
+        </StackPanel>
+        <StackPanel Orientation="Horizontal" Grid.Row="6" HorizontalAlignment="Center">
+
+            <Button  Content="取消" Width="80"  Margin="5,0"  Command="{Binding CancelCommand}" Opacity="0.7" Style="{StaticResource NormalButtonStyle}" />
+            <Button  Content="确认" Width="80"  Margin="5,0"  Command="{Binding SureCommand}" Style="{StaticResource NormalButtonStyle}" />
+        </StackPanel>
+
+
+    </Grid>
+</UserControl>
+
+

+ 28 - 0
BlankApp1/BlankApp1/Views/SystemManageView/Dialogs/AddEditMenuView.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PLCTool.Views.SystemManageView.Dialogs
+{
+    /// <summary>
+    /// AddEditMenuView.xaml 的交互逻辑
+    /// </summary>
+    public partial class AddEditMenuView : UserControl
+    {
+        public AddEditMenuView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 74 - 3
BlankApp1/BlankApp1/Views/SystemManageView/MenuManageView.xaml

@@ -4,9 +4,80 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PLCTool.Views.SystemManageView"
+             xmlns:hc="https://handyorg.github.io/handycontrol"
+             xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
-    <Grid>
-            
+    <Grid >
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <UniformGrid Grid.Row="0" Columns="3">
+            <StackPanel Orientation="Horizontal">
+                <TextBlock Text="菜单名:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                <TextBox  Height="28" Width="120" Text="{Binding MenuName}" />
+                <Button Content="查询" Width="80"  Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
+            </StackPanel>
+
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
+                <Button Content="新增" Width="80"  Margin="5,0,20,0"  Command="{Binding AddCommand}" Style="{StaticResource NormalButtonStyle}" Background="#00BFBF"/>
+                <!--<Button Content="导出Excel" Width="80"  Margin="5,0"  Command="{Binding ExportCommand}" Style="{StaticResource NormalButtonStyle}" />-->
+
+            </StackPanel>
+
+
+        </UniformGrid>
+
+        <DataGrid Grid.Row="1"   Style="{StaticResource MyDataGridSyle}"
+        ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+        ItemsSource="{Binding MenuInfoList}" >
+            <DataGrid.Columns >
+                <DataGridTextColumn Header="菜单Id" Binding="{Binding MenuId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                <DataGridTextColumn Header="菜单名" Binding="{Binding MenuHeader}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="菜单界面" Binding="{Binding TargetView}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="父Id" Binding="{Binding ParentId}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTemplateColumn Header="图标"  CellStyle="{StaticResource MyDataGridCellStyle}">
+                    <DataGridTemplateColumn.CellTemplate>
+                        <DataTemplate>
+                            <Image Source="{Binding MenuIcon}" Width="20" Height="20" HorizontalAlignment="Left"></Image>
+                        </DataTemplate>
+                    </DataGridTemplateColumn.CellTemplate>
+                </DataGridTemplateColumn>
+                <DataGridTextColumn Header="排序" Binding="{Binding Index}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+
+                <DataGridTemplateColumn Header="操作" Width="180" CellStyle="{StaticResource MyDataGridCellStyle}">
+                    <DataGridTemplateColumn.CellTemplate>
+                        <DataTemplate>
+                            <StackPanel Orientation="Horizontal">
+                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+                                 Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding MenuId}" Cursor="Hand" Margin="0,0,10,0" >
+
+                                    <StackPanel Orientation="Horizontal">
+                                        <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
+                                    </StackPanel>
+                                </Button>
+                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+                                 Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding MenuId}" Cursor="Hand" Margin="0,0,10,0">
+
+                                    <StackPanel Orientation="Horizontal">
+                                        <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                    </StackPanel>
+                                </Button>
+
+                            </StackPanel>
+                        </DataTemplate>
+                    </DataGridTemplateColumn.CellTemplate>
+                </DataGridTemplateColumn>
+            </DataGrid.Columns>
+
+        </DataGrid>
+
     </Grid>
-</UserControl>
+</UserControl>

+ 4 - 4
BlankApp1/BlankApp1/Views/SystemManageView/UserManageView.xaml

@@ -5,10 +5,10 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PLCTool.Views.SystemManageView"
              xmlns:hc="https://handyorg.github.io/handycontrol"
-         xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
-         xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
-         mc:Ignorable="d" 
-         d:DesignHeight="450" d:DesignWidth="800">
+             xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
     <Grid >
         <b:Interaction.Triggers>
             <b:EventTrigger EventName="Loaded">