0
WPF 컨트롤 안에 Windows Form 레거시 컨트롤을 래핑하는 중입니다. 몇 가지 Windows Form 컨트롤에서이 작업을 수행하고 있습니다. 예 :에서WinFormHost 객체를 동적으로 설정하는 방법은 무엇입니까?
// WinFormHost control, only AWrapper is shown here, but there
//are BWrapper, CWrapper etc
public class AWrapper : WindowsFormsHost
{
Child=new ALegacyWinFormControl();
}
//WPF control, similarly there are BControl, CControl etc
<UserControl x:Class="AControl">
<local:AWrapper />
</UserControl>
내 ResourceDictionary
나는 각 WPF 컨트롤을 정의해야합니다 eliminate-- 할 중복 하나 개의 층이있다
// each WPF control has a key
<ResourceDictionary>
<DataTemplate x:Key="AControlKey">
<AControl />
</DataTemplate>
<DataTemplate x:Key="BControlKey">
<BControl />
</DataTemplate>
</ResourceDictionary>
각 WPF 컨트롤을 위해 나는 키를 정의하고 각 WindowsFormsHost
랩퍼이며 중복되어 있습니다. 어쨌든 UserControl
개체를 없애고 DataTemplate
을 똑바로 WindowsFormsHost
컨트롤과 연결하면 되나요? 예 : 저는 다음과 같은 것을보고 있습니다 :
// This wouldn't work
<ResourceDictionary>
<DataTemplate x:Key="AControlKey">
<AWrapper/>
</DataTemplate>
<DataTemplate x:Key="BControlKey">
<BWrapper/>
</DataTemplate>
</ResourceDictionary>
그러나 위의 것은 작동하지 않는 것 같습니다. 어쨌든 위의 작업을 할 수 있습니까? 전혀 가능합니까?
편집 :
@dymanoid, 네 오 :
local
는AWrapper
클래스가 정의 된 네임 스페이스에 매핑됩니다. 질문을 업데이트했습니다. – Graviton