[英]How do we set background image of TextBlock in Windows Phone?
[英]How to justify the text of a TextBlock in a Windows Phone application?
我想將對齊文本放入文本塊,但給我一個錯誤。 為什么? 我可以解決嗎?
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Height="220"
HorizontalAlignment="Left"
Margin="102,174,0,0"
Name="textBlock1"
Text="TextBlock sdfg asfgbfgb adf ab afg g "
TextAlignment="Justify"
VerticalAlignment="Top"
Width="255" />
</Grid>
您需要使用<RichTextBox>
,它會很棒。
<RichTextBox TextAlignment="Justify">
<Paragraph>
<Run Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit." />
</Paragraph>
</RichTextBox>
如果您願意, 這是Rudy Huyn的法語教程 。
使用Richtextbox調整文本並在運行時將值綁定到文本,
在.xaml中
<RichTextBox TextAlignment="Justify"
IsReadOnly="True"
Margin="0,0,0,10">
<Paragraph Foreground="#626262"
FontSize="17"
FontStyle="Normal"
FontFamily="Regular" >
<Run x:Name="txtDescription" />
</Paragraph>
</RichTextBox>
和.xaml.cs中
txtDescription.Text ="TextBlock sdfg asfgbfgb adf ab afg g";
顯然,當在TextBlock中使用TextAlignment =“ Justify”時,Windows Phone應用程序意外退出。 這發生了很多,經過一些研究,我發現這是一個錯誤。 而且我也沒有解決方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.