2014-10-07 9 views
1

XAML을 처음 사용하고 TextBlock의 스타일을 정의하려고합니다. 스타일을 설정하는 방법은 MSDN의 this 예제를 참조하십시오 (첫 번째 코드 블록에 있음). 내가 오류 "구성원"배경을 얻고있다"Background"멤버가 인식되지 않거나 액세스 할 수 없습니다.

<Page 
    x:Name="pageRoot" 
    x:Class="MyPrototype.MainPage" 
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:MyPrototype" 
    xmlns:common="using:MyPrototype.Common" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 

<Page.Resources> 
    <!-- TODO: Delete this line if the key AppName is declared in App.xaml --> 
    <x:String x:Key="AppName">MyPrototype</x:String> 
    <x:String x:Key="AppTitle">MyPrototype</x:String> 


    <Style TargetType="TextBlock" x:Key="TitleTextBlockStyle"> 
     <Setter Property="Background" Value="Red"/> 
     <Setter Property="FontFamily" Value="Trebuchet MS"/> 
     <Setter Property="Foreground" Value="White" /> 
     <Setter Property="FontSize" Value="18"/> 
    </Style> 
</Page.Resources> 

<StackPanel Orientation="Horizontal" > 
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="My Prototype Main Page"/> 
</StackPanel> 

"인식되지 않거나 액세스 할 수 없습니다", 나는 이유를 볼 수 없습니다 :

내 XAML입니다. 나는 구문 오류를 추측하지만, 내 삶에 대해 그것이 무엇인지 알 수 없다.

+0

'TextBlock'에는 배경 속성이 없습니다. – thumbmunkeys

+0

@thumbmunkeys 위 링크 된 MSDN 페이지가 Windows 8 Metro 앱에 적용되지 않습니까? –

+0

분명히 아니, 내 대답을 참조 – thumbmunkeys

답변

1

This is the documentation 귀하의 응용 프로그램 유형에 적용됩니다.

이 경우 TextBlock에는 Background 속성이 없습니다.

+0

고마워. 나는 MSDN에서 약간의 실수를 저질러왔다. –

+1

당신을 환영합니다! 나는 너의 고통을 안다, 너무 많은 버전들이있다 ... – thumbmunkeys