Getting the ToastPrompt to wrap long text

Sep 14, 2011 at 3:23 PM

Hi

I'm trying to get the ToastPrompt to wrap text at the moment - and I've not yet succeeded :/

I can see that the default Style template binds the wrapping to {TemplateBinding TextWrapping} but trying to set this or trying to replace it with a simple Wrap doesn't bring the desired effect :/

I'm not sure I entirely understand how the control and styling works for the ToastPrompt - e.g. is the width being set correctly?  

Any help appreciated

Stuart

P.S. Default style is http://coding4fun.codeplex.com/SourceControl/changeset/view/69627#1113269:

<Style TargetType="local:ToastPrompt">
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeSmall}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Overlay" Value="{StaticResource TransparentBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ToastPrompt">
					<Grid
						VerticalAlignment="{TemplateBinding VerticalAlignment}"
                        Background="{TemplateBinding Background}">
						<StackPanel 
                            VerticalAlignment="Bottom" 
							Margin="24, 32, 16, 5" 
							Orientation="{TemplateBinding TextOrientation}">
                            <StackPanel
                                Margin="0,0,16,0"
                                VerticalAlignment="Bottom"
                                Orientation="Horizontal">
                                <Image 
                                    Stretch="None"
                                    Margin="0,0,16,0"
								    Visibility="Collapsed"
								    Name="ToastImage"
                                    VerticalAlignment="Bottom"
								    Source="{TemplateBinding ImageSource}" />
                                <TextBlock 
                                    Text="{TemplateBinding Title}"
								    FontWeight="Bold"
                                    VerticalAlignment="Center"
								    Margin="0"
                                    Padding="0" />
                            </StackPanel>
                            <TextBlock 
                                Text="{TemplateBinding Message}" 
								Margin="0"
                                Padding="0" 
                                TextWrapping="{TemplateBinding TextWrapping}"
                                VerticalAlignment="Center"/>
						</StackPanel>
					</Grid>                     
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Sep 14, 2011 at 3:43 PM

Ah....

Getting somewhere now by looking at the C# source tree....

It seems TextWrapping is somehow tied to TextOrientation - and that TextOrientation will overwrite the template.

Will keep digging - but getting somewhere :)

Stuart

Coordinator
Sep 14, 2011 at 10:10 PM

looks like I actually broke this fixing another issue, logging bug

Coordinator
Sep 14, 2011 at 10:19 PM

Take that back, just did full test, use case already exists. code below properly executes

var toast = new ToastPrompt
{
TextWrapping = TextWrapping.Wrap,
Title = "Basic",
Message = "Testing text body wrapping with a bit of Lorem Ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at orci felis, in imperdiet tortor.",
};
toast.Show();

If this isn't the case, please file a bug with a repo that I can test against along with what version of the tooling you have.

Sep 14, 2011 at 10:24 PM

My code used the 1.4.6 from NuGet (I think!) and that assembly doesn't seem to have a TextWrapping property - it doesn't show in intellisense or in object browser and compiling gives:

Error 1 'Coding4Fun.Phone.Controls.ToastPrompt' does not contain a definition for 'TextWrapping'

I'm confused! There were 2 version 1.4.6 choices on nuget - maybe I got a bad one?

Coordinator
Sep 14, 2011 at 10:57 PM

There are 3 tool kits varients but all are from the same code base and build (and deployed) via a power shell script.

BUT looking at source code, I see what happened, this was checked in after the 1.4.6 :-)  http://coding4fun.codeplex.com/SourceControl/changeset/changes/69627

It is there but not fully deployed :-(