Lorsque l'on regarde dans le code un peu plus, je trouve une partie qui a été soustrait x et y de la largeur et la hauteur, même pensé que je n'étais pas traînant encore l'adorateur. alors j'ai changé le code suivant dans leur exemple:
protected override Size ArrangeOverride(Size finalSize)
{
// desiredWidth and desiredHeight are the width and height of the element that's being adorned.
// These will be used to place the ResizingAdorner at the corners of the adorned element.
double desiredWidth = AdornedElement.DesiredSize.Width;
double desiredHeight = AdornedElement.DesiredSize.Height;
// adornerWidth & adornerHeight are used for placement as well.
double adornerWidth = this.DesiredSize.Width;
double adornerHeight = this.DesiredSize.Height;
topLeft.Arrange(new Rect(-adornerWidth/2, -adornerHeight/2, adornerWidth, adornerHeight));
topRight.Arrange(new Rect(desiredWidth - adornerWidth/2, -adornerHeight/2, adornerWidth, adornerHeight));
bottomLeft.Arrange(new Rect(-adornerWidth/2, desiredHeight - adornerHeight/2, adornerWidth, adornerHeight));
bottomRight.Arrange(new Rect(desiredWidth - adornerWidth/2, desiredHeight - adornerHeight/2, adornerWidth, adornerHeight));
// Return the final size.
return finalSize;
}
au code suivant:
protected override Size ArrangeOverride(Size finalSize)
{
// desiredWidth and desiredHeight are the width and height of the element that's being adorned.
// These will be used to place the ResizingAdorner at the corners of the adorned element.
double desiredWidth = AdornedElement.DesiredSize.Width;
double desiredHeight = AdornedElement.DesiredSize.Height;
// adornerWidth & adornerHeight are used for placement as well.
double adornerWidth = this.DesiredSize.Width;
double adornerHeight = this.DesiredSize.Height;
//Orginal Microsoft code
//topLeft.Arrange(new Rect(-adornerWidth/2, -adornerHeight/2, adornerWidth, adornerHeight));
//topRight.Arrange(new Rect(desiredWidth - (adornerWidth/2), - adornerHeight/2, adornerWidth, adornerHeight));
//bottomLeft.Arrange(new Rect(-adornerWidth/2, desiredHeight - adornerHeight/2, adornerWidth, adornerHeight));
//bottomRight.Arrange(new Rect(desiredWidth - (adornerWidth/2), desiredHeight - adornerHeight/2, adornerWidth, adornerHeight));
topLeft.Arrange(new Rect(-adornerWidth/2, -adornerHeight/2, adornerWidth, adornerHeight));
topRight.Arrange(new Rect(adornerWidth/2, -adornerHeight/2, adornerWidth, adornerHeight));
bottomLeft.Arrange(new Rect(-adornerWidth/2, adornerHeight/2, adornerWidth, adornerHeight));
bottomRight.Arrange(new Rect(adornerWidth/2, adornerHeight/2, adornerWidth, adornerHeight));
// Return the final size.
return finalSize;
}
Je ne l'ai pas connu de bizarreries encore, mais il semble juste.