different behavior of xamlreader

206 views Asked by At

What's the difference between XamlReader in WPF and WP7? I've got XAML file and I want to load it dynamically in my wp7 app. I'm using XamlReader.Load() function. For test purposes I've created simple app in WPF and file loaded perfectly. In wp7 when I try load the same file I've got XamlParseException:

Failed to create a 'System.Windows.Media.PathFigureCollection'

Why it's possible?

Here is this 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>
1

There are 1 answers

1
ColinE On

There are numerous differences between XAML in WPF and WP7. The Silverlight framework used by WP7 is a subset of the WPF framework, for example the ClipToBounds property is not present in Silverlight.

You could try pasting your XAML into a user-control then remove the properties / elements that cause compilation failures.

The bottom line, you cannot expect anything other than pretty trivial WPF XAML to work in Silverlight!