2011-08-03 1 views
1

저는 WPF 및 XAML의 초보자이며 이미 배워야 할 것을 후회하고 있습니다. 처음. 아래 코드를 실행하는 데 오류가 발생하는 이유를 모르겠습니다. WPF 4에서 직접 코드를 복사했습니다. 너희들 중 하나가이 계산에 나를 도울 수 있다면 우리의 내가 너희들에게 큰 호의를 빚을 것'FactoryMethod'특성이 XML 네임 스페이스 'http://schemas.microsoft.com/winfx/2006/xaml'에 존재하지 않습니다.

<Window x:Class="WpfApplication1.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:System="clr-namespace:System;assembly=mscorlib" 
     xmlns:collections="clr-namespace:System.Collections;assembly=mscorlib" 
     xmlns:Person="clr-namespace:Src" 
     Title="MainWindow" Height="354" Width="525"> 
    <StackPanel> 
    <Label Name="lblText" Foreground="BlanchedAlmond" FontWeight="Bold" FontSize="20"> 
     Test 
    </Label> 
    <Label x:FactoryMethod="System:Guid.NewGuid">Test2</Label>  
    <ListBox SelectionChanged="ListBox_SelectionChanged"> 
     <Person:Person FirstName="Deepak" LastName="Sharma"></Person:Person> 
     <Person:Person FirstName="Nidhi" LastName="Sharma"></Person:Person> 
    </ListBox> 
    </StackPanel> 
</Window> 

답변

1

x:FactoryMethod이 문서에 따라 마크 업 컴파일 된 XAML에서 지원되지 않는 XAML 2009 feature입니다.

WPF에서는 XAML 2009 기능을 사용할 수 있지만 WPF 태그가 컴파일되지 않은 XAML 만 사용할 수 있습니다. 마크 업 컴파일 된 XAML 및 BAML 형태의 XAML은 현재 XAML 2009 언어 키워드 및 기능을 지원하지 않습니다. 그 Guid.NewGuid 게다가

Label 그래서 난이가 첫 번째 장소에서 운동을하는데 방법을 모르겠습니다 반환하지 않습니다.

+0

잘못된 코드는 유감이지만 FactoryMethod에 대해 더 우려하고 있습니다. Visual Studio 2010에서 .NET 4.0 빌드의 WPF 응용 프로그램에서 팩토리 메서드를 사용할 수없는 이유가 확실하지 않습니다. XAMLPad 또는 일부 타사 응용 프로그램과 같은 것을 사용해야한다는 의미입니까? – dpak

+0

컴파일되지 않은 XAML에서 컨트롤을 생성해야합니다. 예를 들어 'XamlReader'로 수행 할 수 있지만 컴파일 된 XAML **에서 지원 될 때까지는 그다지 신경 쓰지 않아도됩니다. 그렇지 않으면 상당히 쓸모가 없습니다. –

+0

x : Arguments 태그를 사용하여 비슷한 오류가 발생합니다. 같은 문제로 인한 것입니까? – dpak

0

H.B의 대답은 정확합니다. 당신은 당신이 WPF4 해방을 읽고 말했다 때문에, 여기 MSDN 그것에 대해 말해야하는 것입니다

67 페이지의 시작 페이지 표 2.2를 참조하십시오
"In WPF, you can use XAML 2009 features but only for XAML that is not markup-compiled. Markup-compiled XAML for WPF and the BAML form of XAML do not currently support the XAML 2009 keywords and features."

참조 herehere을.

관련 문제