title: How can i populate a combo box with data from an access database and use it to filter a datagrid?
body: <p>I have a page with a combo box and a datagrid. I have a countries database connected to the datagrid that loads the information from the database and populates the datagrid accordingly. i want to be able to use a combo box to filter the datagrid and just show the information about the country chosen. Is this possible?? Thanks</p>
  
  <p>XAML CODE:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication10.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="369" Width="749"&gt;
      &lt;Grid&gt;
          &lt;DataGrid x:Name="grid1" ColumnWidth="SizeToCells" HorizontalAlignment="Left" Margin="10,59,0,0" VerticalAlignment="Top" Height="270" Width="721"/&gt;
          &lt;ComboBox HorizontalAlignment="Left" Margin="10,31,0,0" VerticalAlignment="Top" Width="120"/&gt;
  
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>XAML.CS:</p>
  
  <pre><code>    using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  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;
  using System.Data.OleDb;
  using System.Configuration;
  
  namespace WpfApplication10
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
              loadgrid();
          }
  
          private void loadgrid()
          {
              OleDbConnection con = new OleDbConnection();
              con.ConnectionString = ConfigurationManager.ConnectionStrings["Connection"].ToString();
              con.Open();
              OleDbCommand cmd = new OleDbCommand();
              cmd.CommandText = "Select * from [Country]";
              cmd.Connection = con;
              OleDbDataReader rd = cmd.ExecuteReader();
              grid1.ItemsSource = rd;
  
          }         
      }
  }
  </code></pre>