2009-05-16 13 views
1

現在のWindowsフォームアプリケーションにWPFを適用しようとしています。この単純なユーザーコントロールを使用すると、そのコントロールのデザイナーはリロードしません。DataTemplate.DataTypeを拒否するデザイナ

これはこのアプリケーションでのみ発生します。クリーンなWindowsフォームプロジェクトを作成し、これらのファイルを追加すると、デザイナーは正常に動作します。

私はVisual Studioのリロードを試し、アプリケーションのクリーニング/再構築を行っています。

アイデア? (これらはListBox内の項目用ですので、x:Keyはオプションではありません)

P.S.コードリストの末尾にある空白行をすべて取り除くにはどうすればよいですか?

詳細:これは、空間を有することによって引き起こされた

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(); 
     } 
    } 
} 

答えて

関連する問題