兩個視圖(Windows)中我開發了具有2種模式切換在MVVM WPF
- 配置模式
- 執行模式
Boths模式將在新窗口中打開的應用程序。我已經創建了配置窗口。
我需要通過按Key F12
或類似的東西來切換2模式....我也必須提示用戶輸入密碼時,從執行切換到配置模式(只需一次durnig會話)我已經輸入密碼屏幕並在配置中實施。
我也很擔心,因爲我已經使用Messenger(Meaditor模式),因此關閉並打開2個不同的窗口將再次註冊代表再次登錄代表...並且我正在啓動Modal windows
。
我們還需要保持兩個視圖活着或我可以殺死其中一個切換。
完全糊塗了有關實現的...
我的App.xaml代碼
/// <summary>
/// Application_Startup
/// </summary>
/// <param name = "sender"></param>
/// <param name = "e"></param>
private void Application_Startup(object sender, StartupEventArgs e)
{
log.Debug("Application_Startup " + Utility.FUNCTION_ENTERED_LOG);
try
{
if (e.Args.Length == 0)
{
AboutDialog.SpashScreen(Utility.TOOL_NAME,
Utility.TOOL_VERSION);
MainView mainForm = new MainView();
mainForm.ShowDialog();
}
else
{
string key = null;
foreach (string arg in e.Args)
{
if (arg.StartsWith("-"))
{
//this is a key
key = arg;
if (key.Equals("-config"))
{
CommandLineArgs.Add(key, "config");
break;
}
if (key.Equals("-start"))
{
CommandLineArgs.Add(key, "start");
}
}
else
{
//should be a value
if (key == null)
{
throw new Exception(
"The command line arguments are malformed.");
}
CommandLineArgs.Add(key, arg);
key = null;
}
}
string config = string.Empty;
foreach (object k in App.CommandLineArgs.Keys)
{
config += CommandLineArgs[k].ToString();
}
switch (config)
{
case "config":
AboutDialog.SpashScreen(
Utility.TOOL_NAME,
Utility.TOOL_VERSION);
MainView mainForm = new MainView();
mainForm.ShowDialog();
break;
case "start" :
ExecutionForm execuForm= new ExecutionForm();
execuForm.ShowDialog();
break;
default:
MessageBox.Show("Incorrect Parameters",
Utility.TOOL_NAME);
Application.Current.Shutdown();
break;
}
}
log.Debug("Application_Startup" + Utility.FUNCTION_EXIT_LOG);
}
catch (Exception ex)
{
log.Error("Application_Startup" + ex.Message, ex);
}
}
感謝您的投票...但至少有禮貌告訴我爲什麼... – Ankesh
這裏沒有真正的問題,除了一些代碼... –