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

2 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

2 comments :

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

    ReplyDelete
  2. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru Dot Net Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete