I am trying to load a listview of mine with the data from my database. And the data will be update periodically.
<ListView Margin="10" Name="lvDataBinding" ></ListView> //frontend
I am now experimenting on using backgroundworker to load the new data but no luck on it
<ListView Margin="10" Name="lvDataBinding" ></ListView> //frontend
ObservableCollection<string> mNames = new ObservableCollection<string>();
public SettingsControl()
{
InitializeComponent();
listview1.ItemsSource = mNames;
mNames.Add("1");
var mWorker = new BackgroundWorker();
mWorker.DoWork += Worker_ListenForNewSMS;
mWorker.RunWorkerAsync();
}
private void Worker_ListenForNewSMS(object sender, DoWorkEventArgs e)
{
while (true)
{
Thread.Sleep(2000);
//fetch and load new data here, cant seems to work
listview1.ItemsSource = "NEWDATA";
}
}
So how could it reload the data async, i do not wan to refresh the page.
I need it to be in a loop so that i could listen to the ddatabase and if there is new entry, it will update the list
I am aware of data blinding but i am very little experience doing that, can anyone provide a example to guide me for that.