1
현재 Windows Forms 응용 프로그램에 WPF를 적용하려고합니다. 이 간단한 사용자 정의 컨트롤을 사용하면 해당 컨트롤의 디자이너가 다시로드되지 않습니다.Designer에서 DataTemplate.DataType을 거부합니다.
이것은이 애플리케이션에서만 발생합니다. Windows Forms 프로젝트를 깨끗하게 만들면이 파일을 추가하면 디자이너가 잘 작동합니다.
Visual Studio를 다시로드하고 응용 프로그램을 정리/다시 작성했습니다.
아이디어가 있으십니까? (이것들은 ListBox의 항목을위한 것이므로 x : Key는 옵션이 아닙니다.)
P. 내 코드 목록에있는 모든 빈 줄을 없애려면 어떻게합니까?
DETAILS :
MyClasses.cs
namespace MyNamespace {
internal class MyClassInternal {}
public class MyClassPublic {}
}
MyUserControl.xaml
<UserControl x:Class="MyNamespace.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyNamespace"
Height="300" Width="300">
<UserControl.Resources>
<DataTemplate DataType="{x:Type local:MyClassInternal}"/> <!--OK-->
<ObjectDataProvider x:Key="ClassPublicKey" ObjectType="{x:Type local:MyClassPublic}"/> <!--OK-->
<!-- Type reference cannot find public type named 'MyClassPublic' -->
<DataTemplate DataType="{x:Type local:MyClassPublic}"/> <!--FAILS-->
</UserControl.Resources>
<TextBlock>Hello World</TextBlock>
</UserControl>
MyUserControl.xaml.cs
using System.Windows.Controls;
namespace MyNamespace {
public partial class MyUserControl :UserControl {
public MyUserControl() {
InitializeComponent();
}
}
}