2
我有一個WPF應用程序,我打開彈出mennu(彈出控件)使用轉義鍵。在該彈出菜單中,當按下按鈕時,我打開文件對話框,按下按鈕時關閉彈出窗口。當我下次按下esc按鈕時,它不會彈出,直到我已經集中另一個程序,例如。重置焦點。有誰知道什麼可能導致這種情況?爲什麼在WPF中顯示一個OpenFileDialog會阻止我的WPF彈出窗口?
編輯
//called when pushing esc
private void ShowSettingsMenu()
{
SettingsMenu.IsOpen = true;
}
//clicking my button, subsequent presses on my esc, doesnt pop it up (the code is run)
private void ImportLicenseButton_Click(object sender, RoutedEventArgs e)
{
SettingsMenu.IsOpen = false; //<- hiding it again
OpenFileDialog filedialog = new OpenFileDialog();
filedialog.Filter = "Xml Files|*.xml";
if ((bool)filedialog.ShowDialog())
{
string fileName = "license.xml";
string destinationFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
if (!string.IsNullOrEmpty(filedialog.FileName))
{
File.Copy(filedialog.FileName, System.IO.Path.Combine(destinationFolder, fileName), true);
}
else
{
MessageBox.Show("Please select a file name");
}
}
this.Cursor = Cursors.None;
}
代碼將有助於診斷... – 2010-11-22 18:29:04