Note that there are some explanatory texts on larger screens.

plurals
  1. POComboBox values disappears after selected when objects used for display
    primarykey
    data
    text
    <p>I have a combobox where I want to display objects and have enum values returned. When first opened the combobox displays the items as supposed, but after a value is chosen it seems to disappear from the list. But if the combobox is active I can use the keyboard to navigate up and down between the other values, so they are in the list but only invisible.</p> <p>I have created a little test application to show my problem. When started the application shows the combobox with all the choices (the two first are type of Object, the third is a String):</p> <p><a href="http://i42.tinypic.com/ak7rll.png" rel="nofollow noreferrer">All choices shown on startup http://i42.tinypic.com/ak7rll.png</a></p> <p>After the blue line is selected and when the combobox is opened again this line is missing:</p> <p><a href="http://i41.tinypic.com/24awgth.png" rel="nofollow noreferrer">Blue line selected and is missing in popup http://i41.tinypic.com/24awgth.png</a></p> <p>When the line with the text "Green" is selected that line is still showing:</p> <p><a href="http://i41.tinypic.com/2en3g2r.png" rel="nofollow noreferrer">Green line selected and still shown in popup http://i41.tinypic.com/2en3g2r.png</a></p> <p>If I had chosen the red line the only thing that would still be in the list is the test "Green".</p> <p>I am using .NET Framework 3.5.</p> <p><b>Any hints or tips to why the elements disappears?</b></p> <hr> <p>Here are all the code needed after starting a blank project in Visual Studio.</p> <p><i>MainWindow.xaml.cs:</i></p> <pre><code>using System; using System.Collections.Generic; using System.Diagnostics; namespace Test { public partial class MainWindow { public MainWindow() { InitializeComponent(); } private ColorComboBoxValue _activeColor; public ColorComboBoxValue ActiveColor { get { return _activeColor; } set { _activeColor = value; Debug.WriteLine("ActiveColor: " + _activeColor.Color); } } } public class ColorList : List&lt;ColorComboBoxValue&gt; { } public class ColorComboBoxValue { public Color Color { get; set; } public Object Object { get; set; } } public enum Color { Red, Blue, Green } } </code></pre> <p><i>MainWindow.xaml:</i></p> <pre><code>&lt;Window x:Class="Test.MainWindow" x:Name="window" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:Test" Title="ComboBoxTest" Height="100" Width="200"&gt; &lt;Window.Resources&gt; &lt;local:ColorList x:Key="ColorList"&gt; &lt;local:ColorComboBoxValue Color="Red"&gt; &lt;local:ColorComboBoxValue.Object&gt; &lt;Path Data="M0,0 L0,30 60,30 60,0 Z" Fill="Red"/&gt; &lt;/local:ColorComboBoxValue.Object&gt; &lt;/local:ColorComboBoxValue&gt; &lt;local:ColorComboBoxValue Color="Blue"&gt; &lt;local:ColorComboBoxValue.Object&gt; &lt;Path Data="M0,0 L0,30 60,30 60,0 Z" Fill="Blue"/&gt; &lt;/local:ColorComboBoxValue.Object&gt; &lt;/local:ColorComboBoxValue&gt; &lt;local:ColorComboBoxValue Color="Green"&gt; &lt;local:ColorComboBoxValue.Object&gt; &lt;System:String&gt;Green&lt;/System:String&gt; &lt;/local:ColorComboBoxValue.Object&gt; &lt;/local:ColorComboBoxValue&gt; &lt;/local:ColorList&gt; &lt;/Window.Resources&gt; &lt;ComboBox ItemsSource="{Binding Source={StaticResource ColorList}}" SelectedItem="{Binding ActiveColor, ElementName=window}"&gt; &lt;ComboBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;ContentPresenter Content="{Binding Path=Object}"/&gt; &lt;/DataTemplate&gt; &lt;/ComboBox.ItemTemplate&gt; &lt;/ComboBox&gt; &lt;/Window&gt; </code></pre>
    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.
 

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