0
我想在表單中顯示一個長句。
有些詞應該是黑色的,有些則是藍色的。
爲此,我添加了不同的textBlocks,併爲每一個設置Foreground屬性,並將它們放置在Horizontal StackPanel中。
但我希望它可以被包裝,並通過設置TextBlock的WrapText屬性它沒有任何效果,因爲它在StackPanel中。
解決方案是什麼?用句子形式將不同風格的長句子包起來
我想在表單中顯示一個長句。
有些詞應該是黑色的,有些則是藍色的。
爲此,我添加了不同的textBlocks,併爲每一個設置Foreground屬性,並將它們放置在Horizontal StackPanel中。
但我希望它可以被包裝,並通過設置TextBlock的WrapText屬性它沒有任何效果,因爲它在StackPanel中。
解決方案是什麼?用句子形式將不同風格的長句子包起來
您應該使用Inlines爲TextBlock的
<TextBlock TextWrapping="Wrap">
<Run Text="This is black text" Foreground="Black"/>
<Run Text=" While this is blue text!" Foreground="Blue"/>
</TextBlock>