WPFToolkit CheckComboBox宽度问题

时间:2012-08-21 10:38:22

标签: c# wpf xaml wpftoolkit

我正在使用应用程序中的CheckComboBox(来自Extended WPF Toolkit),我想制作“textBox”,它显示所选项目有点宽,(事实上,我希望它填写所有CheckComboBox)但我对如何应用样式一无所知。

CheckComboBox with the problem

任何帮助?

谢谢!


当前代码

 <UserControl
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
 <!-- ... -->
 <Label Content="Locale: "/>
 <xctk:CheckComboBox Name="LocaleSelector" ItemsSource="{Binding Locales}" ValueMemberPath="Id" SelectedValue="{Binding SelectedLocales}" Margin="5 2 0 2" />

1 个答案:

答案 0 :(得分:2)

我终于将它放入UserControl.Resources,并将样式应用于CheckComboBox

<Style x:Key="MyCustomStyle" TargetType="{x:Type xctk:CheckComboBox}">
    <Style.Resources>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
        </Style>
    </Style.Resources>
</Style>
<!-- ... -->
<xctk:CheckComboBox Name="LocaleSelector" ItemsSource="{Binding Locales}" ValueMemberPath="Id" SelectedValue="{Binding SelectedLocales}" Style="{StaticResource MyCustomStyle" Margin="5 2 0 2" />