Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Adding and Retrieving data from Combo Box

$
0
0

In the XAML I have this code:

<ComboBox x:Name="CurrencyCB" Header="Coin Face" FontSize="18" Height="70" Width="296" Margin="5,25,0,0" SelectionChanged="CurrencyCB_SelectionChanged"><ComboBoxItem><x:String>
                                Entry1</x:String></ComboBoxItem><ComboBoxItem><x:String>
                                Entry2</x:String></ComboBoxItem></ComboBox>

In the C# I have this code:

private void CurrencyCB_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Choice = CurrencyCB.SelectedValue.ToString();
        }

Then calling it in this code:

private void btn_random_Click(object sender, RoutedEventArgs e)
        {
            txt_response.Text = Choice;
        }
Just for reference, Choice is a String.


Viewing all articles
Browse latest Browse all 18858

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>