C# ComboBoxItem指针引用事件未在UWP中激发? private void HEXComboBoxItem_PointerPressed(对象发送方,PointerRoutedEventArgs e) { } 私有void HSLComboxItem_PointerPressed(对象发送方,PointerRoutedEventArgs e) { }

C# ComboBoxItem指针引用事件未在UWP中激发? private void HEXComboBoxItem_PointerPressed(对象发送方,PointerRoutedEventArgs e) { } 私有void HSLComboxItem_PointerPressed(对象发送方,PointerRoutedEventArgs e) { },c#,uwp,C#,Uwp,pointerPressed事件正常工作,但pointerPressed事件未触发。我不知道为什么?有一个简单的解决方案。它说: 这些事件必须通过thorugh AddHandler方法而不是XAML来处理 SomeButton.AddHandler(PointerPressedEvent, 新指针eventhandler(按下SomeButton_指针),true); 在这种情况下,应该是PointerPressed事件已在组合框中专门处理 如果您想捕获 CoubBox项目的点击事件,您可以考

pointerPressed事件正常工作,但pointerPressed事件未触发。我不知道为什么?

有一个简单的解决方案。它说:

这些事件必须通过thorugh AddHandler方法而不是XAML来处理

SomeButton.AddHandler(PointerPressedEvent,
新指针eventhandler(按下SomeButton_指针),true);

在这种情况下,应该是
PointerPressed
事件已在
组合框中专门处理

如果您想捕获<代码> CoubBox项目的点击事件,您可以考虑使用<代码> TabP< <代码>事件> < /P>


private void HEXComboBoxItem_点击(对象发送方,点击路由Deventargs e)
{
Debug.WriteLine(“tapped”);
}

如果您想在“代码> >组合框< /COD>选择项目之后得到所选项目,您可以考虑使用此方法:


private void组合框\u SelectionChanged(对象发送者,SelectionChangedEventArgs e)
{
变量项=(发件人作为组合框)。选择EdItem作为组合框项;
//做其他事情。。。
}
谢谢

<Grid>
<ComboBox x:Name="ColorRepresentationComboBox" Margin="0,12,0,0"  Width="120" >
<ComboBoxItem x:Name="HEXComboBoxItem" Content="HEX" PointerPressed="HEXComboBoxItem_PointerPressed"/>
<ComboBoxItem x:Name="HSLComboBoxItem" Content="HSL" PointerPressed="HSLComboBoxItem_PointerPressed"/>
</ComboBox>
   </Grid>



private void HEXComboBoxItem_PointerPressed(object sender, PointerRoutedEventArgs e)
{

}

private void HSLComboBoxItem_PointerPressed(object sender, PointerRoutedEventArgs e)
{

}