2016-09-14 7 views
0

Windows Phone 8.1 프로젝트에 대한 사용자 지정 템플릿 컨트롤을 만들려고 노력하지만,하고 그것은 나에게 다음과 같은 예외를 제공 무엇이든 내가 할 :사용자 정의 윈도우 폰 제어를 만들 수 없습니다

는에서 '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

입력해도 위의 사람이하지 않는 이유를 모르겠어요. 템플릿 컨트롤 만들기를 클릭하면 자체 생성 된 템플릿을 의미합니다. 이거 버그 야? –

+0

나는 그런 코드를 자동으로 생성한다고 생각하지 않는다. 그렇다면 버그가되어야한다. –

+0

이것은 완전히 새로운 솔루션입니다. 방금 템플릿 컨트롤을 만들고 응용 프로그램을 실행했습니다. 결과가 여기에 있습니다. 그래서 당신이 말했듯이 버그 일 것입니다. 당신의 도움을 주셔서 감사합니다. –