2016-09-14 7 views
0

を作成することはできません私は私のWindows Phone 8.1のプロジェクトのためのカスタムテンプレートコントロールを作成しようとしていますが、それは私に次の例外を与えるものは何でも私が行いますは、カスタムのWindows Phoneコントロール

はから「System.Typeを」を作成できませんでした。テキスト 'local2:CustomControl1'。

本当に助けていただきありがとうございます。

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:App1"> 

    <Style TargetType="local2:CustomControl1" xmlns:local2="using:App1.Controls"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="local2:CustomControl1"> 
        <Border 
         Background="{TemplateBinding Background}" 
         BorderBrush="{TemplateBinding BorderBrush}" 
         BorderThickness="{TemplateBinding BorderThickness}"> 
        </Border> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</ResourceDictionary> 
Generic.xaml

<Page 
     x:Class="App1.PivotPage" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:controls="using:App1.Controls" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:data="using:App1.Data" 
     xmlns:local="using:App1" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" 
     DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" 
     mc:Ignorable="d"> 
    <Grid> 
     <controls:CustomControl1 /> 
    </Grid> 
</Page> 

CustomControl1.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.InteropServices.WindowsRuntime; 
using Windows.UI.Xaml; 
using Windows.UI.Xaml.Controls; 
using Windows.UI.Xaml.Data; 
using Windows.UI.Xaml.Documents; 
using Windows.UI.Xaml.Input; 
using Windows.UI.Xaml.Media; 

// The Templated Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234235 

namespace App1.Controls 
{ 
    public sealed class CustomControl1 : Control 
    { 
     public CustomControl1() 
     { 
      this.DefaultStyleKey = typeof(CustomControl1); 
     } 
    } 
} 

:ここに私の現在のコードは

PivotPage.xamlです0

ありがとうございます。

答えて

1

はこれを試してみてください:このコードは動作します

<ResourceDictionary 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:App1" xmlns:local2="using:App1.Controls"> 

<Style TargetType="local2:CustomControl1" > 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="local2:CustomControl1"> 
       <Border 
        Background="{TemplateBinding Background}" 
        BorderBrush="{TemplateBinding BorderBrush}" 
        BorderThickness="{TemplateBinding BorderThickness}"> 
       </Border> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

+0

Altough上記1にはない理由を私は知りません。テンプレートコントロールの作成をクリックすると、それは自己生成のものです。これはバグか何か? –

+0

私はそのようなコードを自動生成したとは思わないが、それがバグでなければならない。 –

+0

これは全く新しいソリューションです。私はテンプレートコントロールを作成し、アプリケーションを実行しました。結果はここにあります。あなたが言ったようにバグかもしれません。ご協力いただきありがとうございます。 –

関連する問題