int to System.Windows.GridLength - VB.NET

╄→尐↘猪︶ㄣ 提交于 2019-12-11 02:49:46

问题


How can I convert int to System.Windows.GridLength in VB, NET so that I can set the height of a grid row in Silverlight (xaml).

In xaml file:

<RowDefinition Height="0" x:Name="rowerror"  />

In VB.NET:

rowerror.Height = CType(30, System.Windows.GridLength)

This as I wrote in VB.NET. I know I'm wrong, but how do you do if the int to System.Windows.GridLength so that the height of the "rowerror" whether that be 30?


回答1:


rowerror.Height = new GridLength(30)



回答2:


The MSDN Documentation provides an example of this using a GridLengthConverter..

Dim myGridLengthConverter As System.Windows.GridLengthConverter = New System.Windows.GridLengthConverter()

...

rowerror.Height = CType(myGridLengthConverter.ConvertFromString("30"), GridLength)


来源:https://stackoverflow.com/questions/1961696/int-to-system-windows-gridlength-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!