Trivial databinding in WPF

Viewed 142

I'm trying to fill a combobox with an ObservableList or a List object that I get from a method call (GetYears).

ObjectDataProvider looked promising but when I try to use it I get "x:Key is allowed for resources and dictionary elements only" and run into trouble in where I should place it in my xaml.

Currently I do the same thing using the following snippet but I feel this is against WPF best practices and more WinForms.

public partial class MainWindow : Window
{
  public MainWindow()
  {
    YearComboBox.ItemsSource = GetYears();
}...

I'm looking at the following pages

http://msdn.microsoft.com/en-us/library/aa480224.aspx and this page http://www.codeproject.com/Articles/140621/WPF-Tutorial-Concept-Binding and speed reading the following book "Pro WPF in C# 2010"

My background is more Android/c/c++ - this is my first foray into a .Net/WPF in my quest of learning WPF I have read a few MVVM articles but nothing thorough enough to get the full idea; it's mainly snippets from people who kind-of got it. Anyone have a full MVVM .sln example? Maybe a UML diagram of MVVM? I feel like I need to get a grasp of a big picture to help me out.

2 Answers
Related