I am developing a WPF application that will be displayed in a Full-HD LCD screen (42 inch). In addition, I need to accommodate the controls in absolute positions. In the dev
Here is the transformation that makes the screen resolution 1920x1080 (FullHD) visible in my laptop screen resolution 1366x768:
XAML
C#
static public class HD
{
static public float Width { get { return 1366.0f; } }
static public float Height { get { return 768.0f; } }
}
static public class FHD
{
static public float Width { get { return 1920.0f; } }
static public float Height { get { return 1080.0f; } }
}
static public class HDRatios
{
static public double Width
{
get
{
#if (DEBUG)
return double.Parse((HD.Width / FHD.Width).ToString("0.0"));
#else
return 1;
#endif
}
}
static public double Height
{
get
{
#if (DEBUG)
return double.Parse((HD.Height / FHD.Height).ToString("0.0"));
#else
return 1;
#endif
}
}
The code demonstrates that in development environment (DEBUG flag) the transformation will be applied and in the release version the transformation will not be applied since the Canvas.Left and Canvas.Top are according to the resolution of Full HD.
I hope that this experience will assist others that encounter displaying controls in WPF within a Canvas in absolute metrics.