Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate ComboBox Items when TextBox value changed
    primarykey
    data
    text
    <p>Hi I am beginner using C# trying to produce a WPF(MVVM).</p> <p>I have currently a TextBox &amp; a ComboBox on a Window Form. </p> <p>At the moment, I would like to arrange such that when user input an Access DB file path into the TextBox, the ComboBox will be automatically updated such that its available Items is the Tables Name in the MDB file. When user changed the MDB file path to another, ComboBox Items will be refreshed as well. </p> <p>I have already prepared below Properties in the GUI's ViewModel. </p> <pre><code>... public string MdbDir { get{;} set {; RaisePropertyChanged("MdbDir");} } public List&lt;string&gt; MdbTblList { get{;} set{...; RaisePropertyChanged("MdbTblList");}} ... </code></pre> <p>I have already prepared below method in the Model.</p> <pre><code>... public List&lt;string&gt; ReturnMdbTblList(string mdbDir) { List&lt;string&gt; mdbTblList = new List&lt;string&gt;(); oCat = new ADOX.Catalog(); oCat.ActiveConnection = oConn; foreach (ADOX.Table oTable in oCat.Tables) { mdbTblList.Add(oTable.Name); } return mdbTblList; } ... </code></pre> <p>I have already prepared below in View.xaml</p> <pre><code>... &lt;TextBox Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding MdbDir}" /&gt; &lt;ComboBox Grid.Column="1" Grid.Row="3" SelectedItem="{Binding Path=SelectedMdbTbl,Mode=TwoWay}" ItemsSource="{Binding MdbTblList}"/&gt; ... </code></pre> <p>All I don't know is how to link the Model Method to ViewModel, and to make the ComboBox aware of MdbDir changed. </p> <p>Any idea on what else to add the coding and at the same time minimize the amendment on the current piece of coding?</p> <p>Thanks very much in advance :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload