c# - How, Using MVVM, would I dynamically create a textbox with a bound value, only to destroy it after 5 seconds? -
so, want create textbox @ location on wpf application window, , want give value. wil either integer converted string, or string. how create textbox upon event being triggered, , destroy 5 seconds later?
i need able have multiple of these @ same time, may following: spawn 1 textbox value x wait 2 seconds spawn 1 textbox value y wait 3 seconds destroy first textbox destroy second textbox
etc. thanks.
use items control , specify item template textbox , bind data collection items control.
here possible xaml items control:
<itemscontrol itemssource="{binding textboxdatacollection}"> <itemscontrol.itemtemplate> <datatemplate> <textbox text="{binding path=. }" /> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> you can bind collection example below:
public observablecollection<string> textboxdatacollection { get; set; } now in code if want 3 text boxes collection should 1 below:
textboxdatacollection = new observablecollection<string>() { "", "", "" }; you can retrieve data typed in textbox using same collection back.
once remove or add more strings collection should create more text boxes you.
if fancy enough can have more complex objects other strings in collection.
Comments
Post a Comment