locked
Strange layout bugs RRS feed

  • Question

  • About my code:

    I have a usercontrol which consists of a rectangle and a textblock. The textblock shows the information about the control and the rectangle is used for animation. I also have 4 storyboards defined in usercontrol.resources animating the rectangle.

    This usercontrol is hosted multiple times in a stackpanel and each usercontrol have its MouseDown event refer to the same method.

    This method takes the clicked control and activates its MouseDown storyboard. All controls, which names are equal to the selected, are highlighted, and the rest just animates to default.

    Sounds simple, but the results are horrible. The animation often fails, some controls are highlighted for no reason and so on.

    On this page, there is a preview of the bug:
    alpha.skema.hagen-hansen.dk/TestPage.html
    And here is the code:
    alpha.skema.hagen-hansen.dk/Test.zip

    Alexei Mihalchuk

    Monday, August 11, 2008 12:46 PM

Answers

  • Yes there are some bugs when changing gradient stop colors, the renderer gets confused. If you're in IE, once the colors start getting messed up, try resizing the browser window and you'll see that the gradients magically fix themselves. I reported this bug a while ago so hopefully it will be fixed in the next release. Unfortunately until this is fixed, I don't know of a good workaround.

    Monday, August 11, 2008 12:53 PM

All replies

  • Yes there are some bugs when changing gradient stop colors, the renderer gets confused. If you're in IE, once the colors start getting messed up, try resizing the browser window and you'll see that the gradients magically fix themselves. I reported this bug a while ago so hopefully it will be fixed in the next release. Unfortunately until this is fixed, I don't know of a good workaround.

    Monday, August 11, 2008 12:53 PM
  • After you mentioned resizing, I thought of this code:

    this.RenderTransform = new ScaleTransform();DoubleAnimation changeX = new DoubleAnimation();

    changeX.To = 1.001;

    changeX.Duration = new Duration(TimeSpan.FromSeconds(0.5));

    Storyboard.SetTarget(changeX, this.RenderTransform);

    Storyboard.SetTargetProperty(changeX, new PropertyPath("ScaleTransform.ScaleX"));

    DoubleAnimation changeY = new DoubleAnimation();

    changeY.To = 1.001;

    changeY.Duration =
    new Duration(TimeSpan.FromSeconds(0.5));

    Storyboard.SetTarget(changeY, this.RenderTransform);

    Storyboard.SetTargetProperty(changeY, new PropertyPath("ScaleTransform.ScaleY"));

    Storyboard stBoard = new Storyboard();

    stBoard.AutoReverse = true;

    stBoard.Children.Add(changeX);

    stBoard.Children.Add(changeY);

    stBoard.Begin();

    The change is not visible, but the redraw is still performed. So, it's a waste of resources, but it works! Big Smile 

     

    Monday, August 11, 2008 1:45 PM
  • Very clever, I'll have to try this trick Smile

    Monday, August 11, 2008 2:05 PM