I have a Silverlight 4 application with a ComboBox at the bottom of the form. The drop-down list can contain from 30 to 100 items.
When I first open ComboBox, there is no SelectedItem, the drop-down folder opens up and it displays about 23 entries; it will continue this behavior every time I open the drop-down menu again until I select an item. As soon as I select an item, every time I open the ComboBox, it always opens the drop-down list and makes only 3 entries visible.
I assume that the drop-down folder is limited to three elements, because this is the lower limit of the window when it is maximized on my screen.
How do I get it to display more items, even if the item was previously selected?
Here is an example Silverlight application that demonstrates behavior, both in the browser and outside it.
MainPage.xaml:
<UserControl x:Class="ComboBox_Test.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="650" d:DesignWidth="1024"> <Grid x:Name="LayoutRoot" Background="LightSteelBlue" Loaded="MainPage_OnLoaded"> <Grid.RowDefinitions> <RowDefinition Height="3*" MinHeight="25" MaxHeight="25" /> <RowDefinition Height="35*" MinHeight="200" /> <RowDefinition Height="10*" MinHeight="70" MaxHeight="70" /> <RowDefinition Height="30*" MinHeight="230" MaxHeight="230" /> <RowDefinition Height="*" MinHeight="10" MaxHeight="30" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="12" /> <ColumnDefinition Width="150" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="12" /> </Grid.ColumnDefinitions> <TextBlock Name="lblData" Text="Data:" Grid.Row="1" Grid.Column="1" /> <TextBox x:Name="txtData" Grid.Row="1" Grid.Column="2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" /> <StackPanel x:Name="AccessPanel" Orientation="Vertical" HorizontalAlignment="Left" Margin="5" Grid.Row="3" Grid.Column="2" Visibility="Visible"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="75" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <StackPanel x:Name="CreationPanel" Orientation="Vertical" Grid.Row="1"> <Grid x:Name="CreationRoot"> <Grid.RowDefinitions> <RowDefinition Height="40" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <StackPanel x:Name="TypesPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="0 5 0 5"> <Grid x:Name="TypesRoot"> <Grid.RowDefinitions> <RowDefinition Height="25" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="220" /> <ColumnDefinition Width="220" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Text="Types" FontFamily="Arial" FontSize="12" FontWeight="Bold" Grid.Row="0" Grid.Column="0" /> <ComboBox x:Name="cboTypes" Width="220" Height="30" Grid.Row="1" Grid.Column="0" IsEnabled="True" SelectionChanged="cboTypes_SelectionChanged"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name, Mode=OneWay}" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> </Grid> </StackPanel> </Grid> </StackPanel> </Grid> </StackPanel> </Grid> </UserControl>
MainPage.xaml.cs:
using System; using System.Windows; using System.Windows.Controls; namespace ComboBox_Test { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void UpdateDataText(DataTypeDesc oData) { txtData.Text = String.Format("{0}\n\t{1}", oData.Name, oData.Desc); } private void MainPage_OnLoaded(object sender, RoutedEventArgs e) { object[] aDataTypeDescs = new object[] { new DataTypeDesc() {Name = "Boolean", Desc = "A Boolean value"} , new DataTypeDesc() {Name = "Byte", Desc = "An 8-bit unsigned integer"} , new DataTypeDesc() {Name = "Char", Desc = "A Unicode character"} , new DataTypeDesc() {Name = "Double", Desc = "A double-precision floating-point number"} , new DataTypeDesc() {Name = "float", Desc = "A single-precision floating-point number"} , new DataTypeDesc() {Name = "Int16", Desc = "A 16-bit signed integer"} , new DataTypeDesc() {Name = "Int32", Desc = "A 32-bit signed integer"} , new DataTypeDesc() {Name = "Int64", Desc = "A 64-bit signed integer"} , new DataTypeDesc() {Name = "SByte", Desc = "An 8-bit signed integer"} , new DataTypeDesc() {Name = "UInt16", Desc = "A 16-bit unsigned integer"} , new DataTypeDesc() {Name = "UInt32", Desc = "A 32-bit unsigned integer"} , new DataTypeDesc() {Name = "UInt64", Desc = "A 64-bit unsigned integer"} , new DataTypeDesc() {Name = "A", Desc = "The letter A in the alphabet"} , new DataTypeDesc() {Name = "B", Desc = "The letter B in the alphabet"} , new DataTypeDesc() {Name = "C", Desc = "The letter C in the alphabet"} , new DataTypeDesc() {Name = "D", Desc = "The letter D in the alphabet"} , new DataTypeDesc() {Name = "E", Desc = "The letter E in the alphabet"} , new DataTypeDesc() {Name = "F", Desc = "The letter F in the alphabet"} , new DataTypeDesc() {Name = "G", Desc = "The letter G in the alphabet"} , new DataTypeDesc() {Name = "H", Desc = "The letter H in the alphabet"} , new DataTypeDesc() {Name = "I", Desc = "The letter I in the alphabet"} , new DataTypeDesc() {Name = "J", Desc = "The letter J in the alphabet"} , new DataTypeDesc() {Name = "K", Desc = "The letter K in the alphabet"} , new DataTypeDesc() {Name = "L", Desc = "The letter L in the alphabet"} , new DataTypeDesc() {Name = "M", Desc = "The letter M in the alphabet"} , new DataTypeDesc() {Name = "N", Desc = "The letter N in the alphabet"} , new DataTypeDesc() {Name = "O", Desc = "The letter O in the alphabet"} , new DataTypeDesc() {Name = "P", Desc = "The letter P in the alphabet"} , new DataTypeDesc() {Name = "Q", Desc = "The letter Q in the alphabet"} , new DataTypeDesc() {Name = "R", Desc = "The letter R in the alphabet"} , new DataTypeDesc() {Name = "S", Desc = "The letter S in the alphabet"} , new DataTypeDesc() {Name = "T", Desc = "The letter T in the alphabet"} , new DataTypeDesc() {Name = "U", Desc = "The letter U in the alphabet"} , new DataTypeDesc() {Name = "V", Desc = "The letter V in the alphabet"} , new DataTypeDesc() {Name = "W", Desc = "The letter W in the alphabet"} , new DataTypeDesc() {Name = "X", Desc = "The letter X in the alphabet"} , new DataTypeDesc() {Name = "Y", Desc = "The letter Y in the alphabet"} , new DataTypeDesc() {Name = "Z", Desc = "The letter Z in the alphabet"} }; cboTypes.ItemsSource = aDataTypeDescs; } private void cboTypes_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataTypeDesc oDesc = (DataTypeDesc)(cboTypes.SelectedItem); if (oDesc != null) UpdateDataText(oDesc); } } }
DataTypeDesc.cs:
using System; namespace ComboBox_Test { public class DataTypeDesc { public String Name { get; set; } public String Desc { get; set; } } }