Search

Blend 4 can't handle freezed StreamGeometries in XAML by lexapilot

Closed
as Won't Fix Help for as Won't Fix

2
0
Sign in
to vote
Type: Bug
ID: 771869
Opened: 11/21/2012 10:38:32 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Consider the following simple ResourceDictionary. Pay especially attention to the freeze attribute.
In connection with a StreamGeometry it causes an exception in Blend 4 that displays the message of the ParserParentTypeDoesNotSupportChildren-Resource in Microsoft.Expression.Markup.dll even though the code is working fine at runtime and in VS XAML editor.
Without the freeze attribute the exception is not be thrown by Blend.

I do have a lot of StreamGeometries that I would like to freeze in XAML. But due to this bug it is not "Blendable".

The sample code to reproduce:

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">

<!--If you open this dictionary in Blend 4, Blend will fire an exception with the
        error message:
             Cannot add content to an object of type 'StreamGeometry'.
        ... even though it's working fine at runtime and in VS XAML-editor!-->
<StreamGeometry x:Key="Geo1" po:Freeze="True" >M 0,0 L 0,1 z</StreamGeometry>

<!--This is not freezed and will not cause the exception in Blend 4.-->
<StreamGeometry x:Key="Geo2">M 0,0 L 0,1 z</StreamGeometry>

</ResourceDictionary>
Details (expand)

Product?

Blend

Product Version?

 

Blend 4 SP1 (4.0.20901.0)

Issue Type?

Bug

Repro Steps? (N/A for Suggestion)

It is simple to reproduce. Please see description.
File Attachments
0 attachments
Sign in to post a comment.
Posted by lexapilot on 11/22/2012 at 4:07 AM
Thanks for your response.

In the meantime I did some further interesting tests to check the effect of the freeze attribute when used in XAML.
I created different types of Freezables in XAML (Brushes, different Geometry types and of course StreamGeometry) with and without the freeze attribute and checked then the IsFrozen-State of each of them at runtime in code.

So, MSDN says that all Freezables are NOT frozen per default:
Quote from: http://msdn.microsoft.com/en-us/library/ms750509%28v=vs.100%29.aspx
"For convenience, freezable objects remain unfrozen unless you explicitly freeze them."

BUT!!!: My tests showed, that in opposite to all other Freezables that I used in my test, the StreamGeometry is the only one that IS automatically frozen (IsFrozen=True), when created in XAML even without the Freeze attribute.
Unfortunatly I didn't find any hints about that special behaviour of the StreamGeometry within the MSDN docs.

Whatever! At least for StreamGeometry that is exactly the behaviour that I would expect.
So, the problem has therefore gone. Nothing has to be fixed in Blend, concerning this issue.
Posted by Microsoft on 11/21/2012 at 5:00 PM
Thanks for your feedback.

Unfortunately, we will not be able to address this issue in the near future.

The only workaround I can think of on your end is to split out these resources that you want to freeze into a separate resource dictionary, that you do not include into App.xaml directly, but instead include it programatically into the Application objects' merged dictionaries at runtime. That way, Blend or VS will never see it at design time and everything will work fine at runtime.

Of course, when you do this, and when your refereence a resource from another file, Blend will not be able to find it. But you can then use the design time resources feature to include another dictionary that have thes resources defined without the freeze option. Something like this:

http://xamltag.wordpress.com/2012/02/15/design-time-resources-in-expression-blend-4-silverlight-and-wpf/

Thanks!
Sign in to post a workaround.