user278618
user278618

Reputation: 20222

WrappingText in stackpanel

I have a stackpanel with 2 textblocks. The problem is that my textblocks doesn't wrap a text. What is weird, even if I have only one textblock wrapping also doesn't work.

        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Row="1" Grid.ColumnSpan="2" Margin="0">
            <!--<ContentControl Width="800">-->
                <TextBlock x:Name="textBlock" TextWrapping="Wrap" Text="{Binding Path=StaticTextLibrary.ApplicationSubtitle, Source={StaticResource ResourcesManager}}"  
                        FontSize="14" HorizontalAlignment="Left" Foreground="{StaticResource text}" Opacity="0"  RenderTransformOrigin="0.5,0.5"
                        VerticalAlignment="Bottom" Padding="5" Height="30">
                    <TextBlock.RenderTransform>
                        <CompositeTransform TranslateX="30"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
            <!--</ContentControl>-->
            <TextBlock x:Name="subTitlePostfix" TextWrapping="Wrap" Text="by Credit Suisse©" Margin="6,0,0,0" Opacity="0" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top" HorizontalAlignment="Left" Foreground="{StaticResource text}" Padding="0,4,0,0" >
                    <TextBlock.RenderTransform>
                        <CompositeTransform TranslateX="30"/>
                    </TextBlock.RenderTransform>
            </TextBlock>
        </StackPanel>

Where have I done a mistake?

Upvotes: 0

Views: 801

Answers (2)

MyKuLLSKI
MyKuLLSKI

Reputation: 5325

Why don't you use a WrapPanel from the Silverlight ToolKit?

Upvotes: 4

Louis Kottmann
Louis Kottmann

Reputation: 16618

I copied to code and punched it until it would wrap.
Here are a few notes and a solution:

Your first TextBlock specifies a Height, but 30 is not enough for a second line ==> can't wrap because can't create a second line. Remove Height="30".

Instead of StackPanel, don't you mean WrapPanel? unless you have something special in mind.

I used TranslateTransform x="30" instead of CompositeTransform TranslateX="30", it shouldn't be an issue though.

HTH,

bab.

Upvotes: 1

Related Questions