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.