123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System.Windows;
- namespace HandyControl.Tools.Extension;
- public static class FrameworkElementExtension
- {
- public static double GetValidWidth(this FrameworkElement element)
- {
- if (!double.IsNaN(element.Width))
- {
- if (element.Width > 0)
- {
- return element.Width;
- }
- }
- else
- {
- if (element.ActualWidth > 0)
- {
- return element.ActualWidth;
- }
- if (element.DesiredSize.Width > 0)
- {
- return element.DesiredSize.Width;
- }
- }
- return 0;
- }
- public static double GetValidHeight(this FrameworkElement element)
- {
- if (!double.IsNaN(element.Height))
- {
- if (element.Height > 0)
- {
- return element.Height;
- }
- }
- else
- {
- if (element.ActualHeight > 0)
- {
- return element.ActualHeight;
- }
- if (element.DesiredSize.Height > 0)
- {
- return element.DesiredSize.Height;
- }
- }
- return 0;
- }
- }
|