WPF Windows Formshost vs2008 도구 상자는 모든 Windows Forms 컨트롤을 회색으로 만들었습니다.

StackOverflow https://stackoverflow.com/questions/809664

문제

WPF 앱에서 Windows Formshost를 사용하여 일부 Windows 양식 구성 요소를 사용할 수 있습니다.

<Grid>
    <WindowsFormsHost>

    </WindowsFormsHost>
</Grid>

이것은 모두 오류없이 잘 작동하지만 VS2008의 Toolbox에서 Windows Forms 구성 요소를 드래그하면 모두 회색으로 연결되었습니다. 어떤면에서 이것은 WPF 구성 요소 만 사용할 수 있으므로 의미가 있습니다. 그러나 Windows Forms 구성 요소가 모두 회색으로 만들어지고 사용할 수없는 경우 Windows Formshost에 어떻게 삭제합니까?

도움이 되었습니까?

해결책

WPF 디자이너가 Windows Forms 구성 요소를 지원한다고 생각하지 않습니다. XAML 또는 코드에이를 지정해야합니다. Winforms 버튼을 WPF 응용 프로그램에 추가하는 방법에 대한 간단한 예입니다. 버튼은 설계 표면에 표시되지 않습니다.

<Window x:Class="DataTemplateBind.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Title="Window1" Height="300" Width="300">

    <WindowsFormsHost Height="200" Name="windowsFormsHost1" Width="258" >
        <forms:Button Text="Waaa :("></forms:Button>
    </WindowsFormsHost>
</Window>

추가하십시오 xmlns:forms 기본적으로없는 네임 스페이스.

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