Files
DMS/Views/VariableTableView.xaml.cs

44 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Windows;
using System.Windows.Controls;
using iNKORE.UI.WPF.Modern.Controls;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PMSWPF.Helper;
using PMSWPF.ViewModels;
namespace PMSWPF.Views;
public partial class VariableTableView : UserControl
{
public bool IsLoadCompletion;
public VariableTableView()
{
InitializeComponent();
IsLoadCompletion = false;
}
private async void OnIsActiveChanged(object sender, RoutedEventArgs e)
{
try
{
var _viewModel = (VariableTableViewModel)this.DataContext;
// 判断如果没有加载完成就跳过防止ToggleSwtich加载的时候触发
if (!_viewModel.IsLoadCompletion || !IsLoadCompletion)
return;
ToggleSwitch toggleSwitch = (ToggleSwitch)sender;
await _viewModel.OnIsActiveChanged(toggleSwitch.IsOn);
}
catch (Exception exception)
{
NotificationHelper.ShowMessage($"修改变量表启用,停用时发生了错误:{exception.Message}");
}
}
private void VariableTableView_OnLoaded(object sender, RoutedEventArgs e)
{
IsLoadCompletion = true;
}
}