INotifyPropertyChanged vs. DependencyProperty in ViewModel

When implementing the ViewModel in a Model-View-ViewModel architecture WPF application there seem to be two major choices how to make it databindable. I have seen implementations that use DependencyProperty for properties the View is going to bind against and I have seen the ViewModel implementing INotifyPropertyChanged instead. My question is when should I prefer one … Read more

How do I get a TextBox to only accept numeric input in WPF?

I’m looking to accept digits and the decimal point, but no sign. I’ve looked at samples using the NumericUpDown control for Windows Forms, and this sample of a NumericUpDown custom control from Microsoft. But so far it seems like NumericUpDown (supported by WPF or not) is not going to provide the functionality that I want. … Read more

Difference between SelectedItem, SelectedValue and SelectedValuePath

What is the difference betweeen the following: SelectedItem SelectedValue SelectedValuePath All these dependency properties are defined in Selector class. I often confuse SelectedItem with SelectedValue , and SelectedValue with SelectedValuePath. I would like to know the difference between them, and also when do we use them, especially SelectedValue and SelectedValuePath. Please explain their use with … Read more

The calling thread cannot access this object because a different thread owns it

My code is as below public CountryStandards() { InitializeComponent(); try { FillPageControls(); } catch (Exception ex) { MessageBox.Show(ex.Message, “Country Standards”, MessageBoxButton.OK, MessageBoxImage.Error); } } /// <summary> /// Fills the page controls. /// </summary> private void FillPageControls() { popUpProgressBar.IsOpen = true; lblProgress.Content = “Loading. Please wait…”; progress.IsIndeterminate = true; worker = new BackgroundWorker(); worker.DoWork += new … Read more