优化菜单,通过绑定实体类添加选中事件进行页面跳转
This commit is contained in:
parent
7988187bcc
commit
a4a745e7b8
|
@ -258,18 +258,34 @@ namespace DM_Weight.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DelegateCommand<ListBox> _selectionCommon;
|
private DelegateCommand _selectionCommon;
|
||||||
public DelegateCommand<ListBox> SelectionCommon
|
public DelegateCommand SelectionCommon
|
||||||
{
|
{
|
||||||
get => _selectionCommon ?? (_selectionCommon = new DelegateCommand<ListBox>(SelectionMethod));
|
get => _selectionCommon ?? (_selectionCommon = new DelegateCommand(SelectionMethod));
|
||||||
}
|
}
|
||||||
private void SelectionMethod(ListBox viewName)
|
private void SelectionMethod()
|
||||||
{
|
{
|
||||||
SelectedMenu = viewName.SelectedItem as PremissionDm;
|
//SelectedMenu = viewName.SelectedItem as PremissionDm;
|
||||||
if (SelectedMenu.PremissionName == "退出")
|
//if (SelectedMenu.PremissionName == "退出")
|
||||||
{
|
//{
|
||||||
|
|
||||||
_chkFunction.HIKStopDVRRecord();
|
// _chkFunction.HIKStopDVRRecord();
|
||||||
|
// logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||||
|
// Operator = null;
|
||||||
|
// Reviewer = null;
|
||||||
|
// _regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// //SelectedMenu.Children = SelectedMenu.Children;
|
||||||
|
// // SelectedChildMenu = SelectedMenu.Children[0];
|
||||||
|
// if (!_portUtil.Operate)
|
||||||
|
// {
|
||||||
|
// _regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
if (SelectedMenu != null && SelectedMenu.PremissionName == "退出")
|
||||||
|
{
|
||||||
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||||
Operator = null;
|
Operator = null;
|
||||||
Reviewer = null;
|
Reviewer = null;
|
||||||
|
@ -278,7 +294,7 @@ namespace DM_Weight.ViewModels
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//SelectedMenu.Children = SelectedMenu.Children;
|
//SelectedMenu.Children = SelectedMenu.Children;
|
||||||
// SelectedChildMenu = SelectedMenu.Children[0];
|
//SelectedChildMenu = SelectedMenu.Children[0];
|
||||||
if (!_portUtil.Operate)
|
if (!_portUtil.Operate)
|
||||||
{
|
{
|
||||||
_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
|
_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
|
||||||
|
|
|
@ -27,10 +27,10 @@
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<!--<Image Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Source="/Images/logo.png" />-->
|
<!--<Image Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Source="/Images/logo.png" />-->
|
||||||
<TextBlock Text="交接柜管理系统" Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Foreground="White" FontSize="20" FontWeight="Bold" />
|
<TextBlock Text="交接柜管理系统" Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Foreground="White" FontSize="20" FontWeight="Bold" />
|
||||||
<ListBox Name="ListBoxName" Grid.Column="1" ItemsSource="{Binding PremissionDmList}" HorizontalAlignment="Right" Cursor="Hand">
|
<ListBox Name="ListBoxName" Grid.Column="1" SelectedItem="{Binding SelectedMenu}" ItemsSource="{Binding PremissionDmList}" HorizontalAlignment="Right" Cursor="Hand">
|
||||||
<i:Interaction.Triggers>
|
<i:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="SelectionChanged">
|
<i:EventTrigger EventName="SelectionChanged">
|
||||||
<i:InvokeCommandAction Command="{Binding SelectionCommon}" CommandParameter="{Binding ElementName=ListBoxName}"/>
|
<i:InvokeCommandAction Command="{Binding SelectionCommon}"/>
|
||||||
</i:EventTrigger>
|
</i:EventTrigger>
|
||||||
</i:Interaction.Triggers>
|
</i:Interaction.Triggers>
|
||||||
<ListBox.ItemsPanel>
|
<ListBox.ItemsPanel>
|
||||||
|
|
Loading…
Reference in New Issue