title: Autosizing ComboBox dropdown to content in Silverlight
body: <p>I have this ComboBox in my Silverlight UserControl:</p>
  
  <pre><code>       &lt;ComboBox  
              AutomationProperties.AutomationId="cmbProjects" 
              Grid.Row="0" 
              Grid.Column="2" 
              ItemsSource="{Binding Projects}"
              SelectedItem="{Binding SelectedProject, Mode=TwoWay}"
              Style="{StaticResource DefaultComboBoxStyle}"                       
              &gt;
              &lt;ComboBox.ItemTemplate&gt;
                  &lt;DataTemplate&gt;                   
                      &lt;StackPanel&gt;
                          &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"&gt;
                              &lt;TextBlock Foreground="DarkRed" AutomationProperties.AutomationId="{Binding Number}" Width="100" Margin="0" Text="{Binding Number, Converter={StaticResource StringFormatter},ConverterParameter='\{0\}'}" /&gt;
                              &lt;TextBlock AutomationProperties.AutomationId="{Binding Description}" Text="{Binding Description, Converter={StaticResource StringFormatter},ConverterParameter='\{0\}       '}"  /&gt;
                          &lt;/StackPanel&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ComboBox.ItemTemplate&gt;
          &lt;/ComboBox&gt;
  </code></pre>
  
  <p>The lenghth of most of the items populating the combobox exceeds the width of the control.  When I dropdown the list, the dropdown expands, but not fully to the width of the item content, resulting in content that is clipped a horizontal scrollbar. This does not happen with exact same combobox where content is within the original width of the control.</p>
  
  <p>In WPF, I could simply set the width of the item container to auto; in Silverlight this results in a catastrophic error. I can set the with to a huge number, but the scroll still appears, regardless of the width. Also, in Silverlight 2 beta 2 there was a property DropDownWidth, with one of the options being "Auto", which I don't see in RTM.</p>
  
  <p>I can get around this with a bit of trickery, mainly hiding the horizontal scrollbar and appending a bunch of characters so that the dropdown fully expand to show the item content.  Obviously, this hack not ideal.  Did anyone experience similar problem? Is there something that I'm missing to force the combobox to expand fully without a scrollbar?</p>
  
  <p>ib.</p>