0
votes

Does anyone know:

  1. Why the origin in some controls is at Center of the Bounds,in some at TopRight corner and in some at TopRight - 10px?
  2. How to change the origin of a Control in WPF?

Methods tried:

  1. For getting origin of the Control in a Canvas:myControl.TranslatePoint(new Point(0,0),null);
  2. Tried:

myControl.RenderTransformOrigin = new Point(0.0,0.0); myControl.RenderTransformOrigin = new Point(0.5,0.5); myControl.RenderTransformOrigin = new Point(1.0,1.0); Tried changing VerticalAlignment and HorizontalAlignment. Nothing Happened.

As analysis,I tried putting a Red Line in MouseMove Event which has as start Point the Canvas Origin,and as End point:

myLine.X2 = myControl.TranslatePoint(new Point(0,0),null).X; myLine.Y2 = myControl.TranslatePoint(new Point(0,0),null).Y; This line points in SOME CONTROLS on the Center of control,and in some other controls at the Top-Right corner,But NEVER at Top-Left.

The Alignments of ALL Controls are set to Stretch/Stretch.

1

1 Answers

0
votes

Googling around,I found some interesting explainations of similar scenario,due to DPI changes/settings:I tried simply SWITCHING DPI to 120% from 100% and Back:

WPF now reports another WRONG positioning of controls on my Canvas,but ALL PROBLEMS in my questions,seems now have an explaination,not yet a solution.

How exactely can a wrong DPI set can influence ONLY HitTest,TranslateTransforms and Render process,without influencing Canvas.SetLeft/Right/Top/Bottom or Margin propery or ScaleTransform?

I read about DisableDpiAwarenessAttribute in assembly,but It seems not working… What can be happened?