[Silverlight] TextをWrapする方法


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>