Windows phone 7 keyboard size - windows-phone-7

I want to resize the page when the keyboard appears on the screen.
I was looking for any clue all day but I can't find anything.
In my case. I want to have full page TextBox and some buttons under it.
<Grid x:Name="RootLayout" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<ScrollViewer Margin="0" >
<TextBox TextWrapping="Wrap" Text="TextBox" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" Height="698" Width="480"/>
</ScrollViewer>
<Canvas x:Name="RootMenu" Margin="0,1,0,0" Grid.Row="1" />
</Grid>
</Grid>
I use to thing that the first row will change its size automatically, but it doesn't happening.
Please help me.
///// -----------------------------------------------------------------------------
I'm going to dislike this OS! Proposed solution is not good at all. When the keyboard is visible then I can not scroll it down.
Lets say I want just simple TextBox to let users write something. But it is impossible !!
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True">
<shell:ApplicationBarIconButton IconUri="/icons/appbar.check.rest.png" Text="aplay"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<Grid x:Name="RootLayout" >
<ScrollViewer>
<TextBox Text="TextBox" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" />
</ScrollViewer>
</Grid>

There isn't a way to know for sure if the SIP is displayed. Jaime Rodriguez has a post showing how to make a fairly reliable guess of this.
If you want to have "buttons" that are always displayed then the best, and only reliable, way to do this is to use the ApplicationBar.

Related

How to Superscript some Text in a TextBox/TextBlock Control in windows phone 8?

I'm working on windows phone 8 app, and m stuck here, guys i want to show some text as a superscript either in TextBox or in TextBlock where-ever possible. suggest me how can i obtained it. Thanks
Why don't you use a stackpanel wrapping a couple of textblocks instead? Then adjust the margines on the stuff you want super and subscripted.
<StackPanel Orientation="Vertical">
<TextBlock Text="H2O3" FontSize="40" Margin="0,10"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="H" FontSize="40" />
<TextBlock Text="2" FontSize="40" Margin="0,-20,0,0"/>
<TextBlock Text="O" FontSize="40"/>
<TextBlock Text="3" FontSize="40" Margin="0,10,0,-10"/>
</StackPanel>
</StackPanel>
There's an alternative but it's only available in WP8: Typography.Variants.
I personally prefer this approach as it aligns more with WPF but there are cases where you have to do baseline manipulation or in this instance, margin wrangling. If WPF is any indication, it also requires a font that supports variants which are generally open type/true type only. See Superscript / subscript in hyperlink in WPF for a better explanation.

Weird behaivior of ProgressBar in WP7

So, I'm tryging to use a progress bar in my WP7 Panorama aplication.
There is one page, that is downloadidng data from the web, so I want to indicate that my App is doing something with ProgressBar
<controls:PanoramaItem Header="news">
<Popup Name="myWeatherPopup" IsOpen="False" Width="404" Height="Auto" Margin="0,136,4,293">
<StackPanel>
<ProgressBar Height="Auto" IsIndeterminate="True" Width="400" />
<TextBlock Text="Loading" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
</Popup>
</controls:PanoramaItem>
It basically works as it should. However, there is one tiny (and anoying bug).
The first... run (?) of the dots appears on every panorama item, just under header. After that, it returns on its normal position under news item.
The same thing happens on emulator and Lumia 800.
Image
Have you tried without the Popup, by just setting the Visibility property on the StackPanel?

WP7 - Drag & Drop with nested layouts

I've got a page design as follows:
The layout is as follows:
<ScrollViewer Margin="0" HorizontalAlignment="Left" Height="360" VerticalAlignment="Bottom">
<StackPanel x:Name="spQueuedWeapons" HorizontalAlignment="Left" VerticalAlignment="Bottom">
<ItemsControl ItemsSource="{Binding QueuedCombinations}" HorizontalAlignment="Left">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding ImageName}">
<i:Interaction.Behaviors>
<ex:MouseDragElementBehavior ConstrainToParentBounds="False" />
</i:Interaction.Behaviors>
</Image>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
The problem I'm seeing is that the MouseDragElementBehavior seems to be visually constrained to the bounds of the ScrollViewer.
I want to be able to drag the green boxes to the blue drop target.
The only options I've thought of so far have been to remove the containing ScrollViewer or to simulate the StackPanel layout programmatically.
I'd rather not add manual button based scrolling or programmatic layout if possible.
Does anyone have any ideas?

Windows Phone 7 dev: How highlight selection of ListBox

I have this code in my .xaml file
<ListBox Name="Tracks" Margin="0,0,-12,0" ItemsSource="{Binding AllTracks}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="150">
<TextBlock Text="{Binding Name}" TextWrapping="NoWrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding Artist}" TextWrapping="NoWrap" Margin="12,-3,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="{Binding Album}" TextWrapping="NoWrap" Margin="12,3,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="{Binding Duration}" TextWrapping="NoWrap" Margin="12,6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I put data in my list like that(MediaLibrary library = new MediaLibrary();
Tracks.ItemsSource = library.Songs;).
I can see data on my list but when i select something, the selection doesn't highlighted,
how i can fix it? Thanks...
The phone applies the Accent colour as Foreground to the selected element's VisualTree. But since you're overriding the style for all the elements, it's likely that the colour won't be applied.
Try with a regular TextBlock without any Style, and you'll see.
Here: Windows Phone 7 - Setting style for specific control within selected ListBoxItem I've written a bit in response to a similar problem. Please read at least the original post/problem and my answer to it. It may look overwhelming at first as there's not a small amount of extra XAML, but in fact it is quite easy to follow and once you look at it as a several different aspects (template, styles, visualstates) - it turns out to be .. quite short, paradoxically. Once you read through it, you will probably notice that your problem is almost exactly the same, with the minor difference that the 'animated' property/target from foreground of textbox to a background of the panel..

WP7 - simplest code to set inputfocus TextBox background, foreground

In Windows Phone 7, I'm looking for simple code to set the background and foreground for a TextBox with inputfocus.
I'm doing this in order to comply with the different themes, and my application visually uses background canvases and other controls which need a standard colorset for controls.
NOTE: Regular foreground, background and borderbrush are fine, and set easily:
<TextBox Background="#BFFFFFFF" BorderBrush="#BFFFFFFF" Foreground="Black"
Canvas.Left="297" Canvas.Top="392" FontSize="20" Height="63" Name="textBox8"
Text="10" Width="126" />
If you want to change the appearance of a control in different states, then you should modify the Style for that control and change the values by using the VisualStateManager as illustrated in the answer to this question: Windows Phone 7 (WP7) Change a button's background color on click
In a similar but slightly different question here on SO, I found a solution, using a Border:
<Border Background="{StaticResource KeyToDesiredBackgroundBrush}">
<TextBlock Text="Forget Password" Height="19" Width="156" />
</Border>
My specific solution ended up being the following:
<TextBlock Canvas.Left="73" Canvas.Top="405" FontWeight="Bold" Foreground="White" Height="30" Name="textInflationLabel" Text="Gasoline Inflation (%):" TextAlignment="Right" Width="224" />
<Border Name="BorderInflation" Background="#BFFFFFFF" Height="45" Width="104" Canvas.Left="308" Canvas.Top="395">
<TextBox Background="#BFFFFFFF" BorderBrush="#BFFFFFFF" Foreground="Black" FontSize="20" Margin="-10,-10,0,0" Height="64" Width="125" Name="tbInflation" Text="12" />
</Border>
Frankly, this seems a little hokey. Hopefully in the future, there are simpler ways to perform such standard tasks.

Resources