Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking selected value in ComboBox - SilverLight4
    primarykey
    data
    text
    <p><strong>SOLVED</strong></p> <p>I'm trying to make some actions when specific position is selected from combobox, but can't get it to work, Google gave me answer that doesn't work, though people say it does.</p> <p>So I've got this in XAML:</p> <pre><code> &lt;ComboBox Height="27" HorizontalAlignment="Left" Margin="178,96,0,0" Name="comboBox1" VerticalAlignment="Top" Width="142" SelectionChanged="comboBox1_SelectionChanged" SelectedValuePath="Content"&gt; &lt;ComboBoxItem IsSelected="True"&gt;Szafa&lt;/ComboBoxItem&gt; &lt;ComboBoxItem&gt;Segment&lt;/ComboBoxItem&gt; &lt;ComboBoxItem&gt;Łóżko&lt;/ComboBoxItem&gt; &lt;ComboBoxItem&gt;Stół&lt;/ComboBoxItem&gt; &lt;/ComboBox&gt; </code></pre> <p>And this in XAML.cs</p> <pre><code> private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString() == "Szafa") MessageBox.Show("TEST"); } </code></pre> <p>Also tried this:</p> <pre><code> private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { string UserSelect = comboBox1.SelectedValue.ToString(); if (UserSelect == "Szafa") MessageBox.Show("TEST"); } </code></pre> <p>SilverLight plugin stops on 100% and doesn't show any content. After I remove if condition, it works... What's wrong? </p> <p>SOLVED</p> <p>I solved this via:</p> <pre><code> if ((sender as ComboBox).SelectedValue.ToString() == "Szafa") { MessageBox.Show("TEST"); } </code></pre> <p>For any future people who come here...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload