/// <summary>
/// Get a Pixel Color from UIElement
/// </summary>
/// <param name="UIObject">UI Element</param>
/// <param name="X">X Axis magnitude</param>
/// <param name="Y">Y Axis magnitude</param>
/// <returns></returns>
public static Color GetPixelColor(UIElement UIObject, double X, double Y) {
var bmp = new WriteableBitmap(UIObject, new MatrixTransform());
int index=(int)(bmp.PixelWidth * Y + X);
Color color ;
if (index < bmp.Pixels.Length)
{
int c = bmp.Pixels[index];
color = Color.FromArgb((byte)(c >> 24), (byte)(c >> 16), (byte)(c >> 8), (byte)(c));
}
else {
color = Colors.Black;
}
return color;
}