Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 340997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:40:05+00:00 2026-05-12T10:40:05+00:00

Hi I am creating a listbox containing 2 text boxes each time a user

  • 0

Hi I am creating a listbox containing 2 text boxes each time a user clicks on a button (example controls to demo) and adding them to the stackpanel defined in the XAML.

<StackPanel Name="myStackPanel">
    <Button Name="myButton" Click="myButton_Click">Click to add a new button</Button>
</StackPanel> 

    private void myButton_Click(object sender, RoutedEventArgs e)
    {
        TextBox tb = new TextBox();
        TextBox tb2 = new TextBox();

        tb.Text = "Some text 1";
        tb2.Text = "Some text 2";

        ListView lv = new ListView();
        lv.Name = "anotherLv";
        lv.Items.Add(tb);
        lv.Items.Add(tb2);

        this.myStackPanel.Children.Add(lv);
    }

This works fine.

I need the ability to start a timer when each listview is created that will count down from 5 mins to 0. Once the timer hits 0 the listview associated with that timer will be removed from the screen. The timer will need to be reset back to 5 mins each time their is some activity in the associated listbox (ie some text is typed in, or a mouseover occurs).

As the user has the ability to create any number of these listviews i will need to create a seperate timer for each listview created and then monitor the events for that specific listview and contained controls.

I have a few points i am srugaling to get started with.

1) How will i attach the timer to each listview?
2) How will i monitor the events for each listview and other controls within it to reset the associated timer?

I hope this all makes sense and someone has some pointers for me.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:40:06+00:00Added an answer on May 12, 2026 at 10:40 am

    How will i attach the timer to each listview?

    You could store the timers in a Dictionary<ListViewItem, DispatcherTimer>. That is, a map from the ListViewItem to the associated DispatcherTimer.

    How will i monitor the events for each listview and other controls within it to reset the associated timer?

    You create the items, so you can attach events handlers according to your requirements. For example:

    ListView lv = new ListView();
    lv.Name = "anotherLv";
    lv.Items.Add(tb);
    lv.Items.Add(tb2);
    
    tb.TextChanged += ResetTimer;
    tb2.TextChanged += ResetTimer;
    
    private void ResetTimer(object sender, RoutedEventArgs e)
    {
        //reset timer here
    }
    

    That said, I’d recommend you encapsulate all this logic in a view model instead of trying to do everything directly in the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 182k
  • Answers 182k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer gmpy to the rescue...: >>> import gmpy >>> x =… May 12, 2026 at 4:24 pm
  • Editorial Team
    Editorial Team added an answer The extension has little effect on rankings and all that… May 12, 2026 at 4:24 pm
  • Editorial Team
    Editorial Team added an answer My first thought is that you haven't closed csStream. If… May 12, 2026 at 4:24 pm

Related Questions

Hi I am creating a tab bar controller in xcode and not in interface
Hi guys i am creating a validation for checking if the user has selected
HI, I am using visual studio for creating a msi file for my application.
Hi all I am not sure how to approach this problem. I have a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.