【发布时间】:2011-07-18 15:01:27
【问题描述】:
我有一个带有一些自定义项目的 wpf 组合框。当第二次单击下拉按钮时,我希望关闭下拉菜单,而是重新打开它。我在其他应用程序中看到过类似的问题,我已经在网上寻找解决方案但没有成功。到目前为止的代码如下:
<ComboBox Name="ComboBoxColorLut"
IsEditable="False"
SelectionChanged="ComboBoxColorLut_SelectionChanged"
ToolTip="Color lookup table"
HorizontalContentAlignment="Stretch">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ComboBox.ItemContainerStyle>
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition ></RowDefinition>
<RowDefinition Height="3"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Path=Name}"></TextBlock>
<Rectangle Grid.Row="1" Fill="{Binding LinearGradientBrush}"></Rectangle>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
【问题讨论】:
-
您所期望的是正常行为,如果您再次单击,弹出窗口将关闭。你确定你是点击一次而不是双击?
-
我想我需要将组合框点击模式设置为“按下”,自从突然修复后发生了很多变化。我怀疑设置点击模式解决了它,但我不确定
标签: wpf combobox wpf-controls