Silverlight: Cannot resolve TargetProperty or OMG how hard can it be to debug this cr...p

5 comments
Sorry for the title of this post, but a little bit frustrated after using a looong time to find out why my animations didn't work.

I tried rotating two usercontrols on a page, and I constantly got this runtime-error:

        Cannot resolve TargetProperty (UIElement.Projection).(PlaneProjection.RotationY) on specified object.

My setup was a kind of Master-Detail story, where I wanted the details usercontrol to rotate in when selecting an item in my master-control.
So I already had my ViewModel, my States and Messages setup and working.
Now I just wanted to try to get that sweet rotation thingie going, and that's the part that was giving me some headache:

My VisualState was something like this:

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="Visning">
                <VisualState x:Name="Liste">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="List"
                                        Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                            <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                            <EasingDoubleKeyFrame KeyTime="00:00:00.2500000" Value="90">
                                <EasingDoubleKeyFrame.EasingFunction>
                                    <PowerEase EasingMode="EaseIn"/>
                                </EasingDoubleKeyFrame.EasingFunction>
                            </EasingDoubleKeyFrame>
                            <DiscreteDoubleKeyFrame KeyTime="00:00:00.25" Value="-90" />
                            <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0">
                                <EasingDoubleKeyFrame.EasingFunction>
                                    <PowerEase EasingMode="EaseOut"/>
                                </EasingDoubleKeyFrame.EasingFunction>
                            </EasingDoubleKeyFrame>
                        </DoubleAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Details"
                                         Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.25" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="List"
                                        Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.25" Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Detaljer">
                        …. the opposite….
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

And my two Usercontrols:

        <views:TilbudsListe x:Name="List">
        </views:TilbudsListe>
        <views:TilbudDetaljer x:Name="Details" Visibility="Collapsed">
        </views:TilbudDetaljer>

When using these Storyboards, I get the aforementioned runtime-exception:

        Cannot resolve TargetProperty (UIElement.Projection).(PlaneProjection.RotationY) on specified object.

I tried googling this, I checked my code, my xaml, my naming, my eyes, my keyboard…. etc but just couldn't get this to work.

Finally I saw someones examplecode, looking kind-of half finished I thought:
        <Rectangle x:Name="rectangle" Stroke="Black" Height="113" Width="170" Canvas.Left="102" Canvas.Top="83" Fill="#FFF64040">
                <Rectangle.Projection>
                        <PlaneProjection/>
         </Rectangle.Projection>
        </Rectangle>

At first I had just thought that the empty Rectangle.Projection properties was because of some code he had tried and then forgotten to remove.

But then it struck me; could this be the  "magic" needed for xaml/silverlight to put the missing properties on my usercontrols?

And it was. Here is the revised usercontrols:
        <views:TilbudsListe x:Name="List">
            <views:TilbudsListe.Projection>
                <PlaneProjection/>
            </views:TilbudsListe.Projection>
        </views:TilbudsListe>
        <views:TilbudDetaljer x:Name="Details" Visibility="Collapsed">
            <views:TilbudDetaljer.Projection>
                <PlaneProjection/>
        </views:TilbudDetaljer.Projection>
        </views:TilbudDetaljer>

This obviously (?) works, and my two views now rotate in and out.

Arrrgggggh!
I want the last two hours back!  Now!!

Better luck for anyone reading this…

rgds
Henri Merkesdal

Posted via email from Henris blogg

5 comments :

  1. Oh thank you so much for this post sir!

    ReplyDelete
  2. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    python training in rajajinagar
    Python training in bangalore
    Python training in usa

    ReplyDelete
  3. It’s hard to come by experienced people about this subject,
    but you seem like you know what you’re talking about! Thanks
    Click here to More info.

    ReplyDelete
  4. Hello there! This article could not be written any better!Gadgets Reading through this post reminds me of my previous roommate! He always kept preaching about this. I most certainly will forward this post to him. Pretty sure he's going to have a very good read. I appreciate you for sharing!

    ReplyDelete