Created
August 31, 2015 12:48
-
-
Save devlights/410c52812c3e58d3a9a4 to your computer and use it in GitHub Desktop.
WPFで「ファイルを開く」ダイアログを裏から強制的に閉じる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| using System.Windows; | |
| using System.Windows.Controls; | |
| using System.Windows.Data; | |
| using System.Windows.Documents; | |
| using System.Windows.Forms; | |
| using System.Windows.Input; | |
| using System.Windows.Interop; | |
| using System.Windows.Media; | |
| using System.Windows.Media.Imaging; | |
| using System.Windows.Navigation; | |
| using System.Windows.Shapes; | |
| using OpenFileDialog = Microsoft.Win32.OpenFileDialog; | |
| namespace WpfApplication1 | |
| { | |
| /// <summary> | |
| /// MainWindow.xaml の相互作用ロジック | |
| /// </summary> | |
| public partial class MainWindow : Window | |
| { | |
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| } | |
| private void Button_Click(object sender, RoutedEventArgs e) | |
| { | |
| var openFileDialog1 = new OpenFileDialog(); | |
| openFileDialog1.InitialDirectory = "c:\\"; | |
| openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; | |
| openFileDialog1.FilterIndex = 2; | |
| openFileDialog1.RestoreDirectory = true; | |
| var dis = this.Dispatcher; | |
| Task.Run(async () => | |
| { | |
| await Task.Delay(3000); | |
| await dis.InvokeAsync(() => | |
| { | |
| // モーダルでダイアログ表示されているけど裏の画面の描画は操作できる | |
| lbl.Background = Brushes.Red; | |
| SendKeys.SendWait("{ESC}"); | |
| }); | |
| }); | |
| openFileDialog1.ShowDialog(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment