BrunoLM
BrunoLM

Reputation: 100322

TextWrapping not working on horizontal StackPanel

I have a panorama item

<controls:PanoramaItem Header="Stream" Margin="0,-16,0,0">
    <ListBox Margin="0,-16,0,0" ItemsSource="{Binding Items}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Margin="6,0,0,10">
                    <StackPanel Margin="6,0,0,10" Orientation="Horizontal">
                        <Image Source="{Binding ProfileImage}"
                               VerticalAlignment="Top"
                               Margin="0,4,0,0"
                               Width="48" Height="48"
                        />
<!-- This doesn't work -->
                        <TextBlock Text="{Binding ProfileName}"
                                   TextWrapping="Wrap"
                                   Style="{StaticResource PhoneTextTitle2Style}"/>
                        <TextBlock Text="{Binding RelativeTime}"
                                   Margin="2,10,0,2"
                                   Style="{StaticResource PhoneTextSubtleStyle}"/>
                    </StackPanel>

<!-- This works -->
                    <StackPanel Margin="0,-4,0,17" Orientation="Vertical">
                        <TextBlock Text="{Binding Content}"
                                   TextWrapping="Wrap"
                                   Style="{StaticResource PhoneTextNormalStyle}"/>
                    </StackPanel>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</controls:PanoramaItem>

I need to make ProfileName text wrap and I would like, if possible, to make RelativeTime to float right.

How can I do it?

Upvotes: 0

Views: 1596

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273179

Makes sense, in a horizontal StackPanel there is no obvious Width constraint to make the Textblock wrap. You could add such a constraint, but that requires providing Pixels.

Just looking at the XAML I think that maybe you want a Grid with 3 columns here, not a StackPanel.

Upvotes: 5

Related Questions