[英]Show rest of text after click on TextBlock
At this moment I have a TextBlock
like this: 现在,我有一个像这样的TextBlock
:
<TextBlock MaxLines="4"
Name="DescriptionText"
Grid.Row="1"
Grid.Column="1"
FontWeight="Thin"
Foreground="White"
FontSize="18"
TextWrapping="Wrap"
TextTrimming="WordEllipsis"
Margin="0,10,10,0"/>
I would have to after click on this TextBlock
show rest of text in this 2 lines I set in MaxLines
. 单击此TextBlock
后,我必须在我在MaxLines
设置的这2行中显示其余文本。
Set MaxLines
as 0
in Tapped Event 在点击事件中将MaxLines
设置为0
private void DescriptionText_Tapped(object sender, TappedRoutedEventArgs e)
{
DescriptionText.MaxLines = 0;
}
To toggle between the max line and unset 在最大线和未设置线之间切换
Create event 建立活动
<TextBlock
MaxLines="2"
Name="DescriptionText"
Grid.Row="1"
Grid.Column="1"
FontWeight="Thin"
Foreground="White"
FontSize="18"
TextWrapping="Wrap"
TextTrimming="WordEllipsis"
Margin="0,10,10,0"
Tapped = "DescriptionText_Tapped"/>
And alternate between the desired max and default. 并在所需的最大值和默认值之间切换。
private void DescriptionText_Tapped(object sender, TappedRoutedEventArgs e) {
DescriptionText.MaxLines = DescriptionText.MaxLines == 0 ? 2 : 0;
}
Now every time you tap the text block it will toggle between the two values. 现在,每次点击文本块时,它将在两个值之间切换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.