i'm having a simple ObservableCollection list which i bind to a form using ListCollectionView.
the problem i would like to control the binding method. means that only when i press the OK button then the property is changed.
as now, if i change the "first name" and navigate, then the value is saved.
for example, if i change the "first name" to XXX and navigate next and then back, i would see XXX instead of x...
this is the MainWindow.xaml:
public partial class MainWindow : Window
{
private ListCollectionView view;
private PersonRepository _personRepository;
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
_personRepository = new PersonRepository();
this.DataContext = _personRepository.Persons;
view = (ListCollectionView)CollectionViewSource.GetDefaultView(this.DataContext);
}
private void BackButton_Click(object sender, RoutedEventArgs e)
{
view.MoveCurrentToPrevious();
view.Refresh();
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
}
private void NextButton_Click(object sender, RoutedEventArgs e)
{
view.MoveCurrentToNext();
}
}
and Person class is:
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Age { get; set; }
public string Description { get; set; }
}
the Repository is ObservableCollection with dummy data...
my xaml fields bind as: Text="{Binding FirstName, UpdateSourceTrigger=Explicit}"
You could have
Person
implementIEditableObject
. Then, you would callEndEdit
from the OK button, butCancelEdit
from other navigation buttons.That said, I would find this interface unintuitive.