나는이 같은 몇 가지 이벤트를 무시 UserControl이있는 UserControl을 위해 그리드로부터 발생하지 :WPF는, 어떤 이벤트가
public class MyControl: UserControl
{
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
// handle mouse event up
}
}
내가 antother UserControl을이 컨트롤을 추가를 -> 그리드,이 그리드 이는 MouseUp 등록했다.
public class MyParent: UserControl
{
private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
{
// handle grid mouse event
}
}
그리고 MyParent XAML에서
단순히 있습니다<UserControl ... >
<Grid Name="Grid" MouseUp="Grid_MouseUp">
<my:MyControl Height="250" Width="310" Visibility="Visible" Opacity="1" IsEnabled="True" />
</Grid>
</UserControl>
내가 뭘 알 것은 내가 MyControl 행사를 통해 마우스를 놓을 때 그리드에 의해 캡처 및 MyControl로 연결되지 않는 것입니다, 왜?
MyControl 클래스 내에서 MouseUp 이벤트를 수신하려면 어떻게해야합니까?
편집 MouseDown와 예상대로, 단지 작품 ... 두 이벤트가 너무 차이가 무엇인가도 상위 그리드에 등록되어 있지 이는 MouseUp 모든 작품? EDIT2
확인
, 난 내가 MyParent에 MyControl를 추가하면 내가 문제를 찾은 것 같아 -> 바로 XAML에서 그리드, 모두가 잘 작동하지만, 내가 프로그래밍 "MyParentInstance.Grid.Children을 추가합니다. Add (MyControlInstance) "그런 다음 위의 문제가 있습니다.
컨트롤을 추가하는 코드가 맞습니까?
감사합니다.
그래 난 알아,하지만 MyControl은 프로그램 추가, 그것은 MyParent 자체에 의해 처리되지 않는, 그래서 내가 할 수있는 MyUparent에 직접 MouseUp을 등록하지 마십시오. – user1182622