tags:

views:

43

answers:

1

I have the following xaml with all the binding removed;

<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" Height="20">
  <ComboBox x:Name="ddlDay" Width="30"/>

If I set the width of the combobox to 200 it works but if I set it to 50 it doesn't size past the default.

I'm kinda new to xaml so is this default behavior or what do I do to make the combobox small?

A: 

I'm not able to reproduce the behavior you are describing. I tried it with the following test:

<Window x:Class="ComboWidthSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Height="20">
            <ComboBox ItemsSource="{Binding}" Width="30" />
            <ComboBox ItemsSource="{Binding}" Width="50" />
            <ComboBox ItemsSource="{Binding}" Width="200" />
        </StackPanel>
    </Grid>
</Window>

using System.Linq;

namespace ComboWidthSample
{
    public partial class Window1
    {
        public Window1()
        {
            InitializeComponent();
            DataContext = Enumerable.Range(1, 10).Select(i => "My ComboBox Item " + i).ToList();
        }
    }
}

Are you doing something different than that? Perhaps databinding to the Width property or styling your ComboBox?

Joseph Sturtevant