Different behavior between version. NET 4 and beta 4.5

2 posts, 0 answers
  1. Raphael Dejaegere
    Raphael Dejaegere avatar
    5 posts
    Member since:
    Nov 2009

    Posted 01 Oct 2012 Link to this post


    With release .Net version 4.0 of wpf diagram, we have overrided the OnPositionChanged to prevent the user to move the chart to the left and upward compared to the position (0,0).   If the coordinates of the diagram exceed the point of origin, the position is reset to the origin point.  Ex.: (10, -10) is converted into (0, -10).
    We have updated our solution with the beta 4.5 and the behavior has changed. It is impossible to change the Position property of the diagram in the method "OnPositionChanged."

    I attache a sample project. The source code is in the class "MyDiagram." Download project here

    Could you
    restore the original behavior or offer a solution?


        protected override void OnPositionChanged(Point oldPosition, Point newPosition)
            base.OnPositionChanged(oldPosition, newPosition);
            Point newPoint = newPosition;
            if (newPosition.X > 0)
                newPoint.X = 0;
            if (newPosition.Y > 0)
                newPoint.Y = 0;
            //With the 4.0 DLL version, there is no problem to set the new position
            if (newPoint != newPosition)
                this.Position = newPoint;
            if (newPoint != newPosition)
                //With the 4.5 DLL version, I need to invoke the method to get the same behaviour
                //but the diagram flikers
                Dispatcher.BeginInvoke(new Action(() =>
                                                          this.Position = newPoint;
                                                      }), DispatcherPriority.Render);
            sh.SetText(((int)this.Position.X).ToString("") + "  -  " + ((int)this.Position.Y).ToString(""));
  2. Hristo
    Hristo avatar
    352 posts

    Posted 04 Oct 2012 Link to this post

    Hello Christophe,

    I couldn't download your project but I think I managed to reproduce the issue and got your idea.
    We made a change in the position handling and added an re-entrance check. This re-entrance check is a flag which if true does not allow the code to change the position.
    We introduce it because in order to address several issues:
    1. Inconsistency between changing the position through the UI and through the Position property.
    2. Bugs when panning from the UI and using animations.
    3. Disable changes of the position while position change is in progress.

    We recommend you to use the ViewportChanged event and insert your custom code regarding the position there. It is fired after the operation (position changing) has been completed and you could safely re-change the position there (at that time).

    Hope this helps. Please let us know if you need more info or the suggested solution is not applicable or not working in your case.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top