[Silverlight] TextをWrapする方法
3176 ワード
MaxWidthかWidthが設定されていないとどこでWrapしていいかわからないようです。
そのため、自分の親要素のActualWidthをMaxWidthにバインドすることで解決できそう。
MainView.xaml
<UserControl x:Class="SilverlightApplication3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Button Content="Resize" Click="Button_Click"></Button>
</StackPanel>
<StackPanel x:Name="Parent" Grid.Column="1" Width="300">
<TextBlock
x:Name="tb"
TextWrapping="Wrap"
MaxWidth="{Binding ElementName=*Parent*, Path=ActualWidth}"
Text="テスト22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"></TextBlock>
</StackPanel>
</Grid>
</UserControl>
Author And Source
この問題について([Silverlight] TextをWrapする方法), 我々は、より多くの情報をここで見つけました https://qiita.com/hidetzu/items/a44f30ebe19befcd4ee4著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .