依赖注入顺序修改
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using UIShare.GlobalVariable;
|
||||
using UIShare.ViewModelBase;
|
||||
|
||||
namespace MainModule.ViewModels
|
||||
@@ -15,6 +16,7 @@ namespace MainModule.ViewModels
|
||||
#region 私有字段
|
||||
private string _testStatus;
|
||||
private string _moduleColor;
|
||||
private GlobalInfo _globalInfo;
|
||||
#endregion
|
||||
|
||||
#region 属性
|
||||
@@ -24,11 +26,7 @@ namespace MainModule.ViewModels
|
||||
set => SetProperty(ref _testStatus, value);
|
||||
}
|
||||
|
||||
public string ModuleColor
|
||||
{
|
||||
get => _moduleColor;
|
||||
set => SetProperty(ref _moduleColor, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 命令
|
||||
@@ -37,6 +35,7 @@ namespace MainModule.ViewModels
|
||||
|
||||
public ProtocolStartViewModel(IContainerProvider containerProvider) : base(containerProvider)
|
||||
{
|
||||
_globalInfo = containerProvider.Resolve<GlobalInfo>();
|
||||
StartProtocolCommand = new DelegateCommand(OnStart);
|
||||
}
|
||||
|
||||
@@ -69,8 +68,7 @@ namespace MainModule.ViewModels
|
||||
// 2. 透传名称与颜色参数,使 AutomatedTestingViewModel 能正确初始化
|
||||
var parameters = new NavigationParameters();
|
||||
parameters.Add("Name", TestStatus);
|
||||
parameters.Add("Color", ModuleColor);
|
||||
|
||||
_globalInfo.CurrentOpeningScope = TestStatus;
|
||||
// 3. 在本格子 Region 内请求导航,导航成功后再移除旧的 ProtocolStartView 以释放资源
|
||||
_regionManager.RequestNavigate(regionName, viewName, navResult =>
|
||||
{
|
||||
@@ -102,8 +100,7 @@ namespace MainModule.ViewModels
|
||||
if (navigationContext.Parameters.ContainsKey("Name"))
|
||||
TestStatus = navigationContext.Parameters.GetValue<string>("Name");
|
||||
|
||||
if (navigationContext.Parameters.ContainsKey("Color"))
|
||||
ModuleColor = navigationContext.Parameters.GetValue<string>("Color");
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user