How to get WPF DataBinding-to-an-object to work?

In the click event, how do I access the "object that is being edited You can access a resource in the behind code using FindResource method, see below private void Button_Click(object sender, RoutedEventArgs e) { ObjectDataProvider objectDataProvider = FindResource("DataSourceCustomer") as ObjectDataProvider; _customer = objectDataProvider. Data as Customer; } For your other questions: What is perpetuate? You do not have to create a singleton to databind in WPF if that is your question eventually of course I want the data to be retrieved from a model which reads an XML file or web service, and I want of course my ViewModel to check my model every second or so to see if the data has changed and reflect this on the XAML WPF databinding will automatically update your view of you use an INotifyPropertyChanged object.

Unless for performance reasons you only want to update your view every second or so just stick to normal databinding.

In the click event, how do I access the "object that is being edited" You can access a resource in the behind code using FindResource method, see below. Private void Button_Click(object sender, RoutedEventArgs e) { ObjectDataProvider objectDataProvider = FindResource("DataSourceCustomer") as ObjectDataProvider; _customer = objectDataProvider. Data as Customer; } For your other questions: What is perpetuate?

You do not have to create a singleton to databind in WPF if that is your question. Eventually of course I want the data to be retrieved from a model which reads an XML file or web service, and I want of course my ViewModel to check my model every second or so to see if the data has changed and reflect this on the XAML. WPF databinding will automatically update your view of you use an INotifyPropertyChanged object.

Unless for performance reasons you only want to update your view every second or so just stick to normal databinding.

I want to get an example working in which a model's data continually changes and those changes are represented in XAML, here is an example that I want to get to work where the model has the current DateTime which should be reflected in XAML: stackoverflow. Com/questions/851595/… – Edward Tanguay May 12 '09 at 7:40 I was able to get this example working the way I wanted to using a singleton method here: stackoverflow. Com/questions/852441/… – Edward Tanguay May 12 '09 at 12:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions