title: WPF MVVM Binding Entity Frame Work Results to Combobox
body: <p>i am implementing a mvvm model. i have class called Dep_Class in My Model</p>
  
  <pre><code>using System.ComponentModel;
  
  namespace mency.Models
  {
      class Dep_class : INotifyPropertyChanged
      {
          private string dep_name;
  
          public string Dep_Name
          {
              get { return dep_name; }
              set
              {
                  dep_name = value;
                  OnPropertyChanged("Dep_Name");
              }
          }
  
          public event PropertyChangedEventHandler PropertyChanged;
          public Dep_class()
          {
  
          }
          private void OnPropertyChanged(string propertyName)
          {
              if(PropertyChanged != null)
              {
                  PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
              }
  
          }
  
      }
  }
  </code></pre>
  
  <p>and i have database connected via EntityFramework and this is the generated class from EF</p>
  
  <pre><code>namespace mency
  {
      using System;
      using System.Collections.Generic;
  
      public partial class branch
      {
          public int Branch_ID { get; set; }
          public string Branch_Name { get; set; }
      }
  }
  </code></pre>
  
  <p>On my Page Code i have XAML</p>
  
  <pre><code>&lt;Page x:Name="Departments_page" x:Class="mency.Department"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:local="clr-namespace:mency"
        xmlns:m="clr-namespace:mency.Models"
        mc:Ignorable="d" 
        d:DesignHeight="502" d:DesignWidth="722"
        Title="Department" Initialized="Departments_page_Initialized" Loaded="Departments_page_Loaded"&gt;
      &lt;Page.Resources&gt;
          &lt;m:Dep_class x:Key="dep_class" /&gt;
  
      &lt;/Page.Resources&gt;
  
      &lt;Grid Background="MediumAquamarine"&gt;
  
              &lt;ComboBox x:Name="Branch_cbox" ItemsSource="{StaticResource dep_class}"  /&gt;
  
  
  
      &lt;/Grid&gt;
  </code></pre>
  
  <p>how can i bind the combobox to the loaded results of my database.
  this is my code behind the page :</p>
  
  <pre><code>using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  
  namespace mency
  {
      /// &lt;summary&gt;
      /// Interaction logic for Department.xaml
      /// &lt;/summary&gt;
      public partial class Department : Page
      {
          medical_databaseEntitiescon _dbObj;
  
  
          public Department()
          {
  
  
              InitializeComponent();
  
  
          }
  
          private void Departments_page_Initialized(object sender, EventArgs e)
          {
  
          }
  
          private void Departments_page_Loaded(object sender, RoutedEventArgs e)
          {
              _dbObj = new medical_databaseEntitiescon();
              //ComboBox = _dbObj.branches.ToList(); // I want combobox loaded with the results of this List
          }
      }
  }
  </code></pre>
  
  <p>i am sorry for long question but i wish that someone help me</p>