Ich versuche, einen Text von meinem ComboBox
zu bekommen, um es zu wechseln, aber es gibt immer null
. Was mache ich falsch?ComboBox.Text zeigt immer Null?
XAML:
<ComboBox Name="cbForms" SelectionChanged="cbForms_SelectionChanged" HorizontalAlignment="Left" Margin="10,289,0,0" VerticalAlignment="Top" Width="139">
<ComboBoxItem IsSelected="True">Polygon</ComboBoxItem>
<ComboBoxItem>Rechteck</ComboBoxItem>
<ComboBoxItem>Dreieck</ComboBoxItem>
<ComboBoxItem>Kreis</ComboBoxItem>
</ComboBox>
C# Code:
private void cbForms_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string text = cbForms.Text;
switch (text)
{
case "Polygon":
{
commandText = "SELECT f.bezeichnung, t.X, t.Y, t.id FROM figure05 f, TABLE(SDO_UTIL.GETVERTICES(f.shape)) t";
lblAnz.Content = anzPolygon.ToString();
break;
}
Bin ich etwas fehlt? Danke für jede Art von Hilfe!
Check this out: https://stackoverflow.com/questions/2961118/combobox-selectionchanged-event-has-old-value-not-new-value – praty
gibt es einen Grund, warum Sie nicht usi ng 'Binding'? – XAMlMAX