The problem with listview and timer [modified]
-
Hello, I have WPF application. I use this code with different messages (SetMessage method) throughout the application:
infoMessageDlg = new InfoMessage();
infoMessageDlg.SetMessage("Записи не найдены...");
infoMessageDlg.Show();timer.Interval = TimeSpan.FromMilliseconds(800);
timer.Start();The timer I use is this:
private DispatcherTimer timer = null;
InfoMessage infoMessageDlg = null;public MainWindow()
{
...timer = new DispatcherTimer();
timer.Tick += new EventHandler(timer_Task);
}It means dialog box appears for 800 milliseconds to display some message and closes automatically using this code:
private void timer_Task(object sender, EventArgs e)
{
infoMessageDlg.Close();
timer.Stop();
}It works fine everywhere except in case I click listview item. The listview is bound to some data through its ItemsSource property. What happens? The dialog appears for very short time (almost not noticeable) and closes. It's much more shorter than 800 milliseconds. The code looks like this:
private void lstvTestRuns_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
...listTestLogs.ItemsSource = null;
listTestLogs.ItemsSource = lstTestLogs;if (treeAdditionalInfo.Items.Count == 0 && listTestLogs.Items.Count == 0)
{
infoMessageDlg = new InfoMessage();
infoMessageDlg.SetMessage("Записи не найдены...");
infoMessageDlg.Show();timer.Interval = TimeSpan.FromMilliseconds(800); timer.Start();
}
...
}Does anybody know what's going on here? Thank you in advance for help.
modified on Thursday, April 14, 2011 1:53 AM