Question : How do I  get the selected value from WPF combobox

I am using a Linq to SQL to show some data in the wpf combobox.  I don't know how to retrieve this data from the combobox once a user selects the item.  My Linq to SQL result set has 2 fields.  

PK_StatementDateID
InvoiceDate

I am showing "InvoiceDate" in my combobox, but when I select the value, I need to return "PK_StatementDateID".

here is my code:

any suggestions?
nick
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
//this button sends data to combobox
private void BtnLoad_Click_1(object sender, RoutedEventArgs e)
        {
            Statements_ARDataContext db = new Statements_ARDataContext();

            var tempStatementDate = from t in db.StatementDates
                                      select new { t.PK_StatementDateID, t.InvoiceDate };

            cboStatemenDate.ItemsSource = tempStatementDate.ToList();
        }
1:
2:
3:
4:
5:
6:
<ComboBox x:Name="cboStatemenDate" Height="23"  
                              Width="188" Margin="0,15,232,265" 
                              HorizontalAlignment="Right" 
                              DisplayMemberPath="InvoiceDate"
                              SelectedValuePath ="PK_StatementDateID"
                                 />

Answer : How do I  get the selected value from WPF combobox

Nevermind, I figured it out.

        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var cboID = cboStatemenDate.SelectedValue;
        }
Random Solutions  
 
programming4us programming4us