title: How to do binding of cascading combo boxes?
body: <h2>XAML</h2>
  
  <h2>ComoBox1</h2>
  
  <pre><code>&lt;ComboBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Center" Margin="2,2,0,0" Name="comboBoxServer"  VerticalAlignment="Top" Width="156" ItemsSource="{Binding ServerNameList}"    SelectedValuePath="key" SelectedValue="{Binding serverSelected, Mode=OneWayToSource,UpdateSourceTrigger=PropertyChanged}" &gt;
  
              &lt;i:Interaction.Triggers&gt;
                  &lt;i:EventTrigger EventName="SelectionChanged"&gt;
                      &lt;i:InvokeCommandAction Command="{Binding serverCommand}" CommandParameter="{Binding  ElementName=comboBoxServer,Path=SelectedItem}"/&gt;
                  &lt;/i:EventTrigger&gt;
              &lt;/i:Interaction.Triggers&gt;
          &lt;/ComboBox&gt;
  </code></pre>
  
  <h2>ComboBox2</h2>
  
  <pre><code>&lt;ComboBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Center" Margin="2,2,0,0" Name="comboBoxDBName" VerticalAlignment="Top" Width="156" ItemsSource="{Binding DBNameList}" SelectionChanged="comboBoxServer_SelectionChanged" SelectedValuePath="Key" SelectedValue="{Binding serverSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" &gt;&lt;/ComboBox&gt;
  </code></pre>
  
  <h2>ViewModel</h2>
  
  <pre><code>public class BackUpViewModel : MVVMSupport.ViewModel.ViewModelBase
      {
          List&lt;string&gt; _ServerNameList;
          List&lt;string&gt; _DBNameList;
  
          public List&lt;string&gt; ServerNameList
          {
              get { return _ServerNameList; }
              set
              {
                  _ServerNameList = value;
              }
          }
  
          public List&lt;string&gt; DBNameList
          {
              get { return _DBNameList; }
              set
              {
                  if (_DBNameList != value)
                  {
                      _DBNameList = value;
                      RaisePropertyChanged("DBNameList");
                  }
              }
          }
  
          string _serverSelected;
          public string serverSelected
          {
              get { return _serverSelected; }
              set
              {
                  if (_serverSelected != value)
                  {
                      _serverSelected = value;
                      RaisePropertyChanged("serverSelected");
                  }
              }
          }
  
  
  
          public BackUpViewModel()
          {
  
               BackUpContext servObj = new BackUpContext();
  
              _ServerNameList = servObj.GetServers();
              serverCommand = new RelayCommand(fetchServer);
              _DBNameList = servObj.GetDatabases(serverSelected);            
             }
  public RelayCommand serverCommand { get; set; }
  
   public void fetchServer(object server)
          {            
              serverSelected =  server.ToString();
          }
  </code></pre>
  
  <h2>Model</h2>
  
  <pre><code> public List&lt;string&gt; GetServers()
         {
  
             XmlDocument doc = new XmlDocument();
             doc.Load(@"C:\Users\477340\Desktop\newFile.xml");
             XmlNodeList nodes
                 = doc.SelectNodes("/servers/server");           
             foreach (XmlNode node in nodes)
             {
  
                 lstServerName.Add(node.Attributes["name"].InnerText);
  
             }
             return lstServerName;
         }
  
         public List&lt;string&gt; GetDatabases(string server)
         {
             XmlDocument doc = new XmlDocument();
             doc.Load(@"C:\Users\477340\Desktop\newFile.xml");
             XmlNodeList nodes
                 = doc.SelectNodes("/servers/server");
             foreach (XmlNode node in nodes)
             {
  
                 if (node.Attributes["name"].InnerText == server)
                 {
                     XmlNodeList databases = node.SelectNodes("database");
  
                     foreach (XmlNode db in databases)
                     {
                         lstDBName.Add(db.InnerText);
                     }
                 }
  
  
             }
             return lstDBName;
  
         }         
  </code></pre>
  
  <blockquote>
    <p>When I am Selecting any server in Frist Combo Box that server selected should pass in model class's GetDatabases(string server) and on the basis of this server selected the correspondind database should be populated in second combo box.</p>
  </blockquote>