RoutedEvent并将其捕获到另一个控件中

RoutedEvent并将其捕获到另一个控件中

本文介绍了如何Rais GotFocus RoutedEvent并将其捕获到另一个控件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我的VisualTree看起来像这样:

my VisualTree looks something like that:

DesignerItem
+ VertexControl

DesignerItem
+VertexControl

顺便说一句.


//Create a DesignerItem to make the VertexVisualization moveabel
DesignerItem designerItem = new DesignerItem();

VertexVisualization vertexcontrol = new VertexVisualization();
vertexcontrol.Vertex = v;
//add the VertexVisualization to the DesignerItem
designerItem.Content = vertexcontrol;

Canvas.Children.Add(designerItem);

推荐答案

您是否将Focusable属性设置为true,我尝试使用以下代码来再现您的问题:

Have you set the Focusable property as true, i tried to repro your issue with below code:


<Canvas Background="Transparent" Width="500" Height="500">
    <ListBoxItem Focusable="True" Width="200" Height="20" Name="contentcontrol" GotFocus="contentcontrol_GotFocus">
        <TextBlock Focusable="True" Width="50" Height="20" Text="test" GotFocus="TextBlock_GotFocus"/>   
    </ListBoxItem>
</Canvas>


这篇关于如何Rais GotFocus RoutedEvent并将其捕获到另一个控件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 17:46