I am new to WPF, and am really frustrated by this. I have a combobox that is bound to a DataTable. The DataTable is Filled with a Stored Procedure that returns 4 items: ID, Name, Date, Contact. I want the combobox to work by filling the dropdown with the Name, and associating the ID, so that when the user selects an item I can fill a datagrid with another stored procedure that needs the ID as a parameter in a where clause.
Here is the XAML for the combobox:
<ComboBox x:Name="cbTransmittals" HorizontalAlignment="Left" Margin="0,250,0,0"    VerticalAlignment="Top" Width="500" 
          SelectedValue ="{Binding TransID, Mode=TwoWay}"
          SelectedValuePath ="TransID" 
          DisplayMemberPath="TransName"
          ItemsSource="{Binding Source={StaticResource transmittalsViewSource}}"
          SelectionChanged="cbTransmittals_SelectionChanged"/>
In the Window_Loaded method VS set up the data binding for ViewSource for me. I have put the line that sets the SelectedIndex as a test of my SelectionChanged routine, and to see if it works as expected. At times the selected item is set accordingly, but now it isn't. I am trying to get the text or the corresponding ID to no avail. Mostly when trying to get the SelectedValue I get an exception thrown because of mismatching types (casting to int does not work, and SelectedValuePath gives me a string that is from the XAML paramter above . . . not helpful).
Here is the initialization code from Window_Loaded:
        DocControlMain.dsDocControlTableAdapters.TransmittalsTableAdapter dsDocControlTransmittalsTableAdapter = 
            new DocControlMain.dsDocControlTableAdapters.TransmittalsTableAdapter();
        dsDocControlTransmittalsTableAdapter.Fill(dsDocControl.Transmittals);
        System.Windows.Data.CollectionViewSource transmittalsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("transmittalsViewSource")));
        transmittalsViewSource.View.MoveCurrentToFirst();
        cbTransmittals.SelectedIndex = 5;
How can I use cbTransmittals.SelectedItem, SelectedValue, or something else to retrieve the ID? I have a feeling it is not being bound properly, as I let VS generate the code by dragging the DataSource Element onto the ComboBox in the designer page. I have been googling all day, and still have no working code, yet I can get this functionality to work in a Windows Form app quite quickly.
Thanks for any help, Paul
 
     
    