开发者

Alternative to "DropDownWidth" Property for Combo Box in wpf

开发者 https://www.devze.com 2023-01-09 03:31 出处:网络
I am unable to locate开发者_如何学C a property similar to WindowsForm \"DropDownWidth\" Property for the Combo Box in WPF. Is there a work around to achieve this functionality? I don\'t remember if th

I am unable to locate开发者_如何学C a property similar to WindowsForm "DropDownWidth" Property for the Combo Box in WPF. Is there a work around to achieve this functionality?


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:

  • Customizing the Appearance of an Existing Control by Creating a ControlTemplate
  • ComboBox Styles and Templates
  • Control Styles and Templates
0

精彩评论

暂无评论...
验证码 换一张
取 消