Combobox Elemento seleccionado WPF c #
Quiero obtener el elemento seleccionado en el cuadro combinado wpf. Pero devuelve System.Data.DataRowView. Mi código en xaml:
<ComboBox Name="ddDeputi" Margin="131,85,0,0" Width="327" HorizontalAlignment="Left" VerticalAlignment="Top" Height="22"
SelectedValue="{Binding Path = kodeDep, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"
Validation.ErrorTemplate="{x:Null}" SelectionChanged="ddDeputi_SelectionChanged" Loaded="ddDeputi_Loaded" />
Y en mi .cs:
private void ddDeputi_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ddDeputi.SelectedIndex != -1)
{
string akode = ddDeputi.SelectedValue.ToString();
DaUnitKerja oDa = new DaUnitKerja();
DataSet data = new DataSet();
data = oDa.TampilDir(akode);
ddDir.ItemsSource = data.Tables[0].DefaultView;
ddDir.DisplayMemberPath = data.Tables[0].Columns["unit_kerja"].ToString();
ddDir.SelectedValuePath = data.Tables[0].Columns["kode"].ToString();
ddSubDir.SelectedIndex = -1;
ComboBoxItem cbi = (ComboBoxItem)ddDeputi.ItemContainerGenerator.ContainerFromItem(ddDeputi.SelectedItem);
txtDeputi.Text = cbi.Content.ToString();
}
}