2
所以,讓我們說我有一個DataTemplate
:傳遞單擊複合WPF/XAML活動控制
<DataTemplate x:Key="ProjectsDataItemTemplate">
<ComboBoxItem x:Name="ProjectComboBox"
Opacity="1" HorizontalAlignment="Stretch"
Foreground="#FF80BBD2"
VerticalAlignment="Center" VerticalContentAlignment="Center"
Background="Transparent"
Style="{DynamicResource ComboBoxItemStyle1}">
<StackPanel>
<Label Content="{Binding Name}" Height="32" VerticalContentAlignment="Top"
FontWeight="Bold" Foreground="#FFFEF9F9" AllowDrop="True" />
<TextBlock Text="{Binding Description}"
Foreground="#FF80BBD2"
Padding="5,0,0,10"
FontStyle="Italic" />
</StackPanel>
</ComboBoxItem>
</DataTemplate>
在這種情況下,Label
和TextBlock
兩個重疊的ComboBoxItem
可點擊區域。當我點擊其中一個子控件時,如何忽略和/或傳遞點擊到ComboBoxItem
?
奇怪。我之前通過在Label和TextBlock上添加IsHitTestVisible = False來嘗試。它看起來像你必須將它添加到ComboBoxItem,這似乎有點違反直覺:我想選擇一個ComboBoxItem爲什麼我不希望它測試?無論如何,謝謝你的解決方案! – 2009-10-14 20:58:26