How to create Windows Phone 7 SMS textbox
I'm looking to create a control that is similar to the "bubble" textbox found in the default SMS app. I was able to come close, creating a "bubble" shaped path, with a textbox inside it, but am having issues with the textbox sizing. I have set "AcceptsReturn" on the textbox to True. What I've noticed is that when the number of lines in the textbox increa开发者_StackOverflowses, the textbox disappears from the view (under the SIP). This is not the way the SMS textbox behaves - it always seems to scroll up to show the latest line (whereas my control becomes hidden). Would appreciate any pointers...
[Update] Managed to create this by customizing TextBox template:
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Rectangle Grid.Row="1" StrokeThickness="0" Fill="{TemplateBinding Background}"/>
<ContentControl Grid.Row="1" x:Name="ContentElement" HorizontalContentAlignment="Stretch" Margin="0" Padding="{StaticResource PhoneTouchTargetLargeOverhang}" VerticalContentAlignment="Stretch" FontSize="{StaticResource PhoneFontSizeNormal}" Background="Black" />
<Path Data="M161.25,90.75 L184.25,90.75 L184.25,100.75" HorizontalAlignment="Left" Grid.Row="0" Stretch="Fill" StrokeThickness="0" UseLayoutRounding="False" Width="23" RenderTransformOrigin="0.5,0.5" Fill="{TemplateBinding Background}" Margin="54.75,0,0,0">
<Path.RenderTransform>
<CompositeTransform Rotation="180"/>
</Path.RenderTransform>
</Path>
<Rectangle Grid.Row="2" Fill="{TemplateBinding Background}"/>
<TextBlock x:Name="txtTimeStamp" Grid.Row="2" TextWrapping="Wrap" Padding="{TemplateBinding Padding}" FontSize="{StaticResource PhoneFontSizeSmall}" Text="{Binding Timestamp, Converter={StaticResource dateTimeConverter}, Mode=TwoWay}">
<TextBlock.Foreground>
<SolidColorBrush Color="{StaticResource PhoneTextBoxForegroundColor}"/>
</TextBlock.Foreground>
</TextBlock>
</Grid>
精彩评论