Click here to Skip to main content
15,891,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have BidListView which have Closing Bid Date and Time. It is very short period between Bid opening and Bid closing (2 minutes). There is at the same time few products in bid and as soon one Bid Closing expiring I want Bid List View to be refreshed as then the old bids will disapear from screen.

Does anybody have any suggestion how to implement this?

What I have tried:

Tried to use thread but I am beginner and it is too complicate for me
Posted
Updated 27-Aug-19 10:30am
Comments
[no name] 23-Jun-19 13:15pm    
https://docs.microsoft.com/en-us/dotnet/framework/wpf/data/how-to-create-and-bind-to-an-observablecollection
Sinisa Janjetovic 23-Jun-19 18:47pm    
This is not that, but thank you for your effort. I need something what will refresh on specific time
BillWoodruff 23-Jun-19 20:57pm    
Is your data (bids) being accessed through the web, or some other streaming service ?
Sinisa Janjetovic 24-Jun-19 5:43am    
No, I am accesing it localy, it is desktop application
BillWoodruff 24-Jun-19 5:51am    
Then, I think you have already found a solution using 'ObservableCollection ... yes ?

1 solution

You can use Timer with 2 minutes interval and MVVM with INotifyPropertyChanged and it'll check for updates after every two minutes and Property Changed will update the wpf UI for you automatically. Just a simple example can be like below

C#
public class PersonViewModel : INotifyPropertyChanged
{
	private string _name;
	private Timer _timer;

	public string Name
	{
		get { return _name; }
		set
		{
			_name = value;
			RaisePropertyChanged("Name");
		}
	}

	public PersonViewModel()
	{
		_timer = new Timer(UpdateModel, null, 0, 2000);
	}

	private void UpdateModel(object state)
	{
			//   Call Service Or Db or whatever and update Name property
	}

	public event PropertyChangedEventHandler PropertyChanged;
	private void RaisePropertyChanged(string property)
	{
		PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
	}
}


ObservableCollection is a good choice in MVVM if you're using any collections
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900