none
System.InvalidOperationException

    Question

  • Hello
    I have created a WPF web application . The same WPF application works fine as a windows application but inside browser it gives the exception. :

    System.InvalidOperationException: The Storyboard.TargetProperty path '(0).(1).[0]' does not point to a DependencyProperty.

    This exception is removed if I comment the following code from my file :

    <!--<EventTrigger.Actions>
                        <BeginStoryboard>
                          <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="HighlightRectangle" Storyboard.TargetProperty="(Rectangle.Fill).(LinearGradientBrush.GradientStops)[0]" To="0.5" Duration="0:0:0.25"/>
                            <DoubleAnimation Storyboard.TargetName="HighlightRectangle" Storyboard.TargetProperty="(Rectangle.Fill).(LinearGradientBrush.GradientStops)[1]" To="1" Duration="0:0:0.25"/>
                          </Storyboard>
                        </BeginStoryboard>
                      </EventTrigger.Actions>-->

    Any help?

    Tuesday, March 07, 2006 9:20 PM

Answers

  •  
    This is not a PartialTrust issue, because I can repro using XamlView.
    I believe this is by design:  there is no property (Offset, in this case) specified on the GradientStop in the PropertyPath.
     
    The following PropertyPath syntax does work:
     
    Storyboard.TargetProperty="(Rectangle.Fill).(LinearGradientBrush.GradientStops[0].(GradientStop.Offset)"
     
     
    An easier way to do this is to use "Direct Targeting" instead, in which a TargetName is specified that points to the x:Name of a GradientStop.  That way, a long , confusing path can be avoided.  Here's a complete example:
     
    <Page
        Name        = "Root"
        xmlns       = "
    http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x     = "
    http://schemas.microsoft.com/winfx/2006/xaml"
        Background  = "Navy">
        
        <Canvas>
        <Rectangle Name="Animate" Width="150" Height="150" Canvas.Top="50" Canvas.Left="50">
            <Rectangle.Fill>
                <LinearGradientBrush
                    StartPoint="0,0"
                    EndPoint="1,1"
                    MappingMode="RelativeToBoundingBox">
                    <LinearGradientBrush.GradientStops>
                        <GradientStopCollection>
                            <GradientStop x:Name="target1" Color="Navy"         Offset=".1" />
                            <GradientStop x:Name="target2" Color="MediumPurple" Offset=".9" />
                            <GradientStop Color="LightBlue"  Offset="1" />
                        </GradientStopCollection>
                    </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Rectangle.Fill>
            <Rectangle.Triggers>
                <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation
                                    Storyboard.TargetProperty   = "Offset"
                                    Storyboard.TargetName       = "target1"
                                    To                          = "0.5"
                                    BeginTime                   = "0:0:0"
                                    Duration                    = "0:0:1" />
                                <DoubleAnimation
                                    Storyboard.TargetProperty   = "Offset"
                                    Storyboard.TargetName       = "target2"
                                    To                          = "1"
                                    BeginTime                   = "0:0:0"
                                    Duration                    = "0:0:1" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Rectangle.Triggers>
        </Rectangle>
        </Canvas>
     
    </Page>
     
     
    Some further details: The most likely explanation for "works fine as a windows application but inside browser it gives the exception" is that the RoutedEvent was never raised in the Windows application but was raised in the web app version.
     
    This error is a runtime error, because the path validation doesn't happen until the BeginStoryboard occurs.  Hence if the associated RoutedEvent does not fire, the validation would not occur, and there would be no error.
     
    Hope this helps...
    Tuesday, March 14, 2006 12:23 AM