Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. The problem with listview and timer [modified]

The problem with listview and timer [modified]

Scheduled Pinned Locked Moved WPF
helpcsharpwpfquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tesic Goran
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups