示例#1
0
 public static Size GetSize(s.FrameworkElement element)
 {
     if (!double.IsNaN(element.ActualWidth) && !double.IsNaN(element.ActualHeight))
     {
         return(new Size((int)element.ActualWidth, (int)element.ActualHeight));
     }
     else
     {
         return(new Size((int)(double.IsNaN(element.Width) ? -1 : element.Width), (int)(double.IsNaN(element.Height) ? -1 : element.Height)));
     }
 }
示例#2
0
 public static void SetSize(s.FrameworkElement element, Size size)
 {
     element.Width  = size.Width == -1 ? double.NaN : size.Width;
     element.Height = size.Height == -1 ? double.NaN : size.Height;
 }