문제

usercontrol이 있고 VS에 의해 생성 된 기본값이 있으며 TextBlock 만 추가됩니다.

<UserControl x:Class="MyNameSpace.Presentation.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="myControl">
    <Grid>
        <TextBlock x:Name="SomeTextBox" Text="SomeText"></TextBlock>
    </Grid>

이제이 컨트롤의 몇 가지 인스턴스를 코드 뒤에서 동적으로 Parent Control의 Wrappanel에 넣었습니다. MyControl 인스턴스에서 왼쪽 마우스 버튼 클릭을 처리하고 싶습니다. 다음 코드가 있습니다.

<UserControl x:Class="Minimo.Presentation.FirstParent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Presentation="clr-namespace:Minimo.Presentation"
Height="300" Width="300">
<WrapPanel Name="wrapPanelOfMyControls" MyControl.MouseLeftButtonDown="WrapPanel1_OnMouseLeftButtonDown">
</WrapPanel>

이벤트 핸들러에서 나는 약간의 조치를 취하고 작동합니다. 그러나 XAML 파일을 편집 할 때 다음과 같은 오류가 발생합니다. 첨부 가능한 속성 'MouseleftButtondown'은 'MyControl'유형에서 찾을 수 없었습니다. 이 문제를 해결하는 방법?

도움이 되었습니까?

해결책

이것은 XAML 컴파일러/디자이너의 버그 일 뿐이며 안전하게 무시할 수 있습니다. 그러나보다 친밀하게 알고있는 유형을 지정하여 "수정"할 수 있습니다.

UIElement.MouseLeftButtonDown="WrapPanel1_OnMouseLeftButtonDown"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top