我在Windows 10应用中使用了Blend 2015生成的一些示例数据。我想在运行时使用示例数据。
samplesata xaml文件如下:
<ViewModels:HomeViewModel xmlns:ViewModels="using:ForeStory.ViewModels" Caption="Euismod fames diam sem sit" IsDataLoaded="True" >
<ViewModels:HomeViewModel.Events>
<ViewModels:Event Category="Sed aliquam cras" DateOfEvent="04/24/2015 10:21:19" Title="Vestibulum nam"/>
<ViewModels:Event Category="Dis curae aenean quisque" DateOfEvent="04/24/2015 10:21:19" Title="Class integer maecenas"/>
<ViewModels:Event Category="Donec etiam fusce vivamus praesent" DateOfEvent="04/24/2015 10:21:19" Title="Duis curabitur adipiscing"/>
<ViewModels:Event Category="Lorem aliquam" DateOfEvent="04/24/2015 10:21:19" Title="Parturient nunc phasellus mauris"/>
<ViewModels:Event Category="Blandit vestibulum dictumst nullam" DateOfEvent="04/24/2015 10:21:19" Title="Consequat accumsan aliquet bibendum est"/>
<ViewModels:Event Category="Amet commodo leo" DateOfEvent="04/24/2015 10:21:19" Title="Convallis hac aptent morbi auctor"/>
<ViewModels:Event Category="Dictum cubilia mus facilisi ante" DateOfEvent="04/24/2015 10:21:19" Title="Dignissim congue conubia cursus eleifend"/>
<ViewModels:Event Category="Arcu egestas" DateOfEvent="04/24/2015 10:21:19" Title="Nulla faucibus habitant proin dapibus"/>
<ViewModels:Event Category="Libero augue facilisis" DateOfEvent="04/24/2015 10:21:19" Title="Lectus elementum nec"/>
<ViewModels:Event Category="Dolor vestibulum per sed" DateOfEvent="04/24/2015 10:21:19" Title="Inceptos ligula litora non"/>
</ViewModels:HomeViewModel.Events>
当我使用XamlReader.Load加载xaml时,收到此错误:
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in mscorlib.ni.dll but was not handled in user code
WinRT information: The property '%0' was not found in type '%1'. [Line: 1 Position: 73]
我假设这是运行时的命名空间问题,但我不知道如何使用新的&#34;使用&#34;语法。
答案 0 :(得分:0)
您不会通过XamlReader.Load
加载示例数据 - 用于读取XAML UI。通常,Blend会为您创建一个封装数据的类,但如果您需要手动加载它,则应使用Windows.UI.Xaml.Application.LoadComponent
。