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

Related Questions

I am creating a simple listbox filter that takes the user input and returns
I am creating 5 thread here using ThrdFunc. Here each thread update the listBox.
When creating a web application, and lets say you have a User object denoting
I am creating a listbox with itemsource of type dataview. I want to scroll
In silverlight, I'm creating a listbox at runtime. The listbox displays on the page
I am creating checked list box with the following template: <Style x:Key=CheckBoxListStyle TargetType={x:Type ListBox}>
I have a situtation. Im creating Listbox in Silverlight Navigation App and as datatemplate
I am creating a timeline control that uses listbox to place my items on
I've got a ListBox that contains an alphabetized list of words. For each letter,
I have a ListBox that contains a number of User items that are DataTemplate

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.