I'm also getting started in WPF, but to begin with, I've hear it's BAD to use fields in databinding (which you will use a lot in WPF). You need to use properties (One of the biggest advantages is to use INotifyPropertyChanged), but I've heard it's also good practice to consolidate all your fields and datacontexts inside one MainViewModel like so:
public class MainViewModel
{
MyDataContext datacontext = new MyDataContext();
}
public class MyDataContext
{
public static List<string> FieldName = new List<string>();
}
(IMPORTANT: This does not implement FieldName as a property, I didn't implement it for the sake you read the post below, just wrote that to demonstrate how to encapsulate properties and objects into one DataContext)
This lets you have only one DataContext established while still letting you access other ones inside the main one. Also, don't forget to use DependencyProperty, or implement INotifyPropertyChanged in your class with fields so you get notified when it changes.
Here is a simple property implementation for demonstration:
private string _MyProperty;
public string MyProperty
{
get { return _MyProperty;}
set { _MyProperty = value;}
}
To start with, you need to convert that field into a property, here is a post explaining that:
How to create a property for a List<T>
Then don't forget to implement INotifypropertychanged if you want your changes to reflect on your UI: Implementing INotifyPropertyChanged - does a better way exist?