如何获取xaml中字符串的行数? 我有以下字符串:
string test = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam non
sapien ac est suscipit luctus ut ut nulla. Nulla vitae turpis id nisl ultrices
lacinia. Mauris laoreet lectus eu urna congue dapibus. Nulla facilisi. Etiam
tincidunt diam congue lectus ullamcorper placerat. In sed vehicula sem, sit
amet laoreet felis.";
我已将此字符串放入xaml的框架中。看起来像这样:
如何获取框架内字符串的行数?
我尝试了以下操作:
int numLines = (int)lbl_txt_Tijdstip5_Lang.LineHeight;
Debug.Write(numLines);
但是,它返回了-1
,在这种情况下,它应该返回24
。
编辑:
Xaml代码:
<StackLayout>
<AbsoluteLayout VerticalOptions="FillAndExpand">
<Frame HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TranslationY="10" TranslationX="12.5" HeightRequest="500" WidthRequest="295">
<StackLayout Orientation="Vertical" Padding="0" HorizontalOptions="FillAndExpand">
<Label x:Name="lbl_Tijdstip6" FontSize="26" TextColor="#CD5C52" TranslationY="0" XAlign="Center" YAlign="Start"/>
<Label x:Name="lbl_txt_Tijdstip6_Lang" FontSize="17" XAlign="Center" TranslationY="0" YAlign="End"/>
</StackLayout>
</Frame>
</AbsoluteLayout>
</StackLayout>