Activation of the rectangle



  • How do you move a rectangle to push the button? I tried this XAML code, but I get InvalidOperationException:

    It's not possible to resolve all references to the properties of the Sanvas.Top. Check that the relevant facilities maintain such properties.

         <Canvas>
        <Rectangle Canvas.Top="200" Name="redRectangle" Canvas.Left="200"  Fill="Red" Stroke="Blue" MinHeight="50" MinWidth="50"></Rectangle>
        <Button  Canvas.Top="250" Canvas.Left="10" >move left
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="redRectangle" From="200" To="50" Duration="0:0:5"
                                             Storyboard.TargetProperty="Canvas.Top">
                            </DoubleAnimation>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Button.Triggers>
        </Button>
    </Canvas>
    


  • Try this:

    Storyboard.TargetProperty="(Canvas.Top)"
    

    It should be the right syntax for the attached property.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2