버튼 인 클릭 된 UIElement의 자식 요소를 가져오고 싶습니다. 어쩌면 거기에 간단하고 짧은 해결책이 있을까요? 나는이 답변을 잠시 수색했지만 이해하기 쉽고 사용하기 쉬운 해결책을 찾지 못했습니다. 나는이 질문과 관련된 어떤 종류의 도움에 감사 할 것이다. 내가 지금이
코드 :클릭 된 UIElement 하위를 찾는 방법
private new void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender == (sender as UIElement))
{
//TODO: getting controls name that is placed inside clicked UIElement
}
}
편집 :
이 UIElement에이 ResourceDictionary의 템플릿을 사용 ContentControl을 것을 언급하고 싶었다. 내 XAML 코드는 모양이 목적
Source
이 속성은 이벤트를 발생시킨 개체에 대한 참조를 포함 위해 활용할 수 MouseButtonEventArgs
의 두 가지 속성이 있습니다이
<ContentControl Style="{StaticResource DesignerItemStyle}">
<Button x:Name="btnAdd" Content="add function" IsHitTestVisible="True"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
</ContentControl>
, 당신도 '보낸 사람을 사용할 수 있습니다 '또는'e.Source'를 사용하십시오. 그렇지 않으면'e.OriginalSource'를 조사해야 할 수도 있습니다. –