Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to change cursor in file open

$
0
0

Hi,

I have a wpf application in which I open a fileDialog in main window and then open file based on the file name selected in fileDialog. When click open button, I want to change to wait cursor and after file is opened, change cursor back to arrow. The code is,

public void button_OpenDocument_Click(object sender, RoutedEventArgs e)
{
   OpenFileDialog openFileDialog = new OpenFileDialog();
   if (openFileDialog.ShowDialog() == true)
   {
       this.Cursor = Cursors.Wait;
       open file...          
       this.Cursor = Cursors.Arrow;
   }
}

However, wait cursor never show up. But if I do not reset cursor to arrow after file is opened, then wait cursor appears after file is opened. It seems that cursor is only effective after exiting this event handler. So how to set cursor to wait before file is opened and back to arrow after? Thanks.

York


York


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>