问题描述
我是WPF和XAML的完全新手,但我已经很遗憾首先尝试学习它.我不确定为什么在运行下面的代码时出错,我直接从WPF 4发布的书中直接复制了它.如果你们中的任何一个可以帮助我解决这个问题,我们将欠你们一个大忙:
I am complete newbie to WPF and XAML and I am already regretting trying to learn it in the first place. I am not sure why the error in running the code below, I copied it directly from a WPF 4 unleashed book. If any of you guys can help me in figuring this our I will owe you guys a big favor:
<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>
推荐答案
x:FactoryMethod 是 XAML 2009功能,根据文档,标记编译的XAML不支持该文件.
x:FactoryMethod
is a XAML 2009 feature, which according to the documentation are not supported in markup compiled XAML.
此外, Guid.NewGuid
不会返回 Label
,因此我不确定这应该如何解决.
Besides that Guid.NewGuid
does not return a Label
so i am not sure how this is supposed to work out in the first place.
这篇关于XML命名空间"http://schemas.microsoft.com/winfx/2006/xaml"中不存在属性"FactoryMethod"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!