I'm fairly new to WPF and I've been reading many tutorials and yet while I could find many guides that showed how to bind data to textboxes and such, I couldn't find anything about navigating such data through back/forward/etc. buttons.
This is my current situation: I have a Customer class containing data on a single customer and a Customers class which is an ObservableCollection of customer. Then data is loaded from an sqlite database (and this opens another can of worms because I don't know the exact approach for working this out but it doesn't really pertain to the current issue since I more or less got it to work) and every customer is added to the collection.
Then in the ViewModel for the main form I have the following stuff:
private Customer _objCustomer;
private Customers _customers;
private Customer _selectedCustomer;
public Customer Selection { get { return _selectedCustomer; }
set
{
if (object.ReferenceEquals(value, _selectedPartecipante)) { return; }
_selectedCustomer = value;
base.OnPropertyChanged("Selection");
}
}
public Customers customers { get { return _partecipanti; }
set { _customers = value; base.OnPropertyChanged("customers"); } }
public Customer customer { get { return _objCustomer; }
set { _objCustomer = value; base.OnPropertyChanged("customer"); } }
public string Name { get { return _objCustomer.Name; } set { _objCustomer.Name = value; base.OnPropertyChanged("Name"); } }
public int Id { get { return _objCustomer.Id; } }
public SubscriptionsViewModel()
{
_customers = Customers.LoadCustomers(); //This one loads the items from the database
_objCustomers = _customers.First();
_selectedCustomer = _objCustomer;
}
This is probably wrong but I still can't find a way to fix it, what am I supposed to work to get navigation working? And how do I get the data in the current record to be saved when pressing a certain button on the form?
Try to put the exact property in OnPropertyChanged("Customers"); In your case, the property is lower case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.