1
我有一些自定义项目的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>
你期待的是正常的行为,如果你再次点击,弹出关闭。你确定你点击一次而不是双击它吗? – anivas
我想我需要设置combobox clickmode为'按',出现了相当多的变化,因为这是突然修复..我怀疑设置clickmode解决了它,但我不知道 – mtijn