WPF和WP7中的XamlReader有什么区别? 我有XAML文件,我想在我的wp7应用程序中动态加载它。我正在使用XamlReader.Load()函数。 出于测试目的,我在WPF中创建了简单的应用程序,文件加载完美。 在wp7中,当我尝试加载相同的文件时,我得到了XamlParseException:
无法创建'System.Windows.Media.PathFigureCollection'
为什么会这样?
这是XAML:
<Canvas Width="110" Height="113" ClipToBounds="True" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Path Fill="#FF000000">
<Path.Data>
<PathGeometry FillRule="Nonzero" Figures="M27.966,79.165C23.747,89.502,20.437,100.215,18.032,111.309L7.278,111.309C2.427,99.541 0,84.985 0,67.646 0,50.181 2.383,30.859 7.151,9.68L19.932,13.225C14.405,29.131 11.643,47.312 11.643,67.773 11.643,75.62 12.043,82.519 12.844,88.466L13.098,88.466C14.827,82.939,16.428,78.593,17.905,75.429L27.966,79.165z M101.738,87.075L94.082,98.594C88.936,94.922 82.27,91.211 74.087,87.451 73.75,95.683 71.621,101.943 67.7,106.25 63.774,110.552 58.31,112.705 51.311,112.705 43.931,112.705 37.961,110.791 33.406,106.973 28.853,103.16 26.575,98.34 26.575,92.52 26.575,86.358 29.273,81.25 34.673,77.203 40.071,73.155 46.651,71.129 54.414,71.129 57.91,71.129 60.718,71.339 62.827,71.759L62.827,44.297C47.556,44.297,35.556,43.958,26.826,43.284L27.207,30.943C34.841,32.169 44.119,32.779 55.044,32.779 57.07,32.779 59.663,32.696 62.827,32.525L62.827,8.542 74.658,8.542 74.658,31.704C79.38,31.45,86.235,30.459,95.221,28.728L95.221,41.321C89.694,42.166,82.842,42.862,74.658,43.411L74.658,74.229C83.643,77.305,92.666,81.592,101.738,87.075z M62.192,84.102C59.873,83.301 57.324,82.901 54.536,82.901 50.151,82.901 46.313,83.848 43.022,85.743 39.733,87.647 38.088,89.986 38.088,92.769 38.088,95.342 39.353,97.369 41.884,98.848 44.416,100.323 47.514,101.06 51.183,101.06 54.896,101.06 57.572,99.786 59.218,97.232 60.864,94.678 61.855,90.303 62.192,84.102z M95.348,22.654L86.426,26.387C84.824,19.258,82.754,13.479,80.225,9.048L89.654,5.188C92.057,9.915,93.955,15.735,95.348,22.654z M109.771,17.466L100.787,21.262C99.229,14.089,97.158,8.289,94.59,3.86L104.077,0C106.439,4.724,108.34,10.547,109.771,17.466z" />
</Path.Data>
</Path>
</Canvas>
答案 0 :(得分:1)
WPF中的XAML与WP7之间存在许多差异。 WP7使用的Silverlight框架是WPF框架的子集,例如Silverlight中不存在ClipToBounds
属性。
您可以尝试将XAML粘贴到用户控件中,然后删除导致编译失败的属性/元素。
最重要的是,除了非常简单的WPF XAML之外,你不能指望在Silverlight中工作!