tags:

views:

36

answers:

2

Hi Experts,

I am unable to locate a property similar to WindowsForm "DropDownWidth" Property for the Combo Box in WPF. Is there a work around to achieve this functionality?

Please help! Thanks in advance.

Regards,

Samar

A: 

use the value like....

<ComboBox Width="85" Height="21.96" />

That will set the size of the box won't it?

Edited & corrected a mistake!

loxxy
umm sry, my bad n535.
loxxy
Oh no no no loxxy..!!!! I am talking about the Width and height of the drop down area when the combo box is clicked and not the width and height of the combo box itself.
samar
A: 

I don't remember if there is such property in a combobox, but you always can alter a default control template. In your case you should specify a width property of a popup element in a control template. Here is a sample code, taken from one of the WPF themes from Codeplex:

 <ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
   ...
      <Popup ... Width="100" >
   ...
 </ControlTemplate>

This is a general idea. You can look in a themes source code fore more information. This MSDN pages can also be helpful:

n535
I tried the following but it did not work. <UserControl.Resources> <ControlTemplate x:Key="popupTemplate" TargetType="{x:Type ComboBox}"> <Popup Width="10000" /> </ControlTemplate> </UserControl.Resources>I also tried the ControlTemplate part in my combobox xaml but it did not work. Do you have any working code with you or anything similar??
samar
You can search for an example inside a theme file (from codeplex). It is just too big to paste here, just open a theme file, for example BureauBlue.xaml, and search for this line: <ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
n535