当我尝试获取画布的宽度和高度时,都返回-1#.IND
Dim ControlWidth as double = MyCanvas.Width
Dim ControlHeight as double = MyCanvas.Height
答案 0 :(得分:3)
-1#.IND
为Double.NaN
,表示宽度和高度设置为auto
。要获得以像素为单位的维度(/ units?),您应该使用ActualWidth
和ActualHeight
。
Dim ControlWidth As Double = MyCanvas.ActualWidth
Dim ControlHeight As Double = MyCanvas.ActualHeight