Open ghost opened 7 years ago
I think the Effective Pixel from UWP is the best approach
The problem with any 'fixed' scale measurement is that it's going to make the app look strange depending on the relative size/density of the screen. A phone might be 1366x768 on a 5" screen... A big screen might be 3000x2000 and 40". Defining the layout at the pixel level means a LOT of real time calculations to make everything work out right.
Relative sizes is good, but at this time, text doesn't work that way and it ends up being painful to get text to match the visuals.
Using an abstract 'pixel' that always maps to a similar size on any given platform regardless of the number of pixels needed to make up the 'pixel' makes a consistent experience across platforms easier and more natural. Allowing 'fractional' pixels or scale override allows the developer to do all the work themselves if they wish to.
Silverlight had integer coordinates only btw
See https://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.uselayoutrounding(v=vs.110).aspx and SnapToDevicePixels mentioned there and the note on changes at .net 4.6. Was using that property (set to true) when sharing XAML between WPF and Silverlight
When setting a measurement such as Height, Width, Thickness, Margin, etc. it should be clear what to expect with regards to the rendered size on all render targets.
WPF defines one unit as 1/96th of an inch (Source) Silverlight defined one unit as one pixel (Source) UWP Applications appear to use pixels (Source)