Undesired bottom margin in (standard) 1080p layout template for a Windows Phone 8.1 app - xaml

When I run my Windows Phone 8 app on the 8.1 1080 emulator, there's a black bottom margin on all its pages (interestingly, it actually doesn't appear when I'm viewing any of these pages in the Design view).
Initially, I thought it may be as a result of my custom laid-out PhoneApplicationPage. So, I decided to create a new PhoneApplicationPage and not make any changes i.e. Visual Studio's auto-generated Portrait PhoneApplicationPage. This is its xaml:
<phone:PhoneApplicationPage
x:Class="App.Views._1080p"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Red">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,0">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
</Grid>
</Grid>
The only change I've made is add a red Background property for the Grid just to better highlight the problem.
I've not made any changes to the code-behind.
Unfortunately, the problem persisted:
If I add an App Bar to the xaml, the problem becomes exacerbated.
This is the App Bar's xaml:
<!-- APP BAR -->
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar
x:Name="appBar"
IsVisible="True"
IsMenuEnabled="True"
Mode="Default"
Opacity="1" >
<!-- APP BAR ICONS -->
<shell:ApplicationBarIconButton
IconUri="a"
Text="Search"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
And this is what it looks like:
Any idea what's going on? And what I need to change to fix this problem? Any guidance would be much appreciated. I should add the problem does happen when running the app on a 1080p device too (i.e. not only a problem on the emulator).

Here is the explanation: on Windows Phone 8.1, the ApplicationBar's height is not fixed anymore, it depends on the device screen size. In order to not break existing 8.0 apps layouts, they added that black bar.
The height of this black bar is 12px (height of the 8.0 AppBar - 8.1 AppBar).
To remove it, you'll have to migrate the app to Windows Phone 8.1.

Related

ContentDialog's buttons are not shown in a Windows Phone 8.1 app if the BottomAppBar is defined

I would like to show a ContentDialog on first launch of my app, to show the EULA to the end user.
It seems that if an AppBar is defined in the calling page the two buttons in the dialog are not visible, an empty area with the same size of the command bar area defined in the calling page, is shown instead.
This is the markup on the ContentDialog:
<ContentDialog
x:Class="MyApp.EulaPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TERMS OF USE"
PrimaryButtonText="i agree"
SecondaryButtonText="cancel"
PrimaryButtonClick="OnAgreeButtonClick"
SecondaryButtonClick="OnCancelButtonClick">
<Grid x:Name="ContentPanel" Margin="0,0,0,0" >
<Grid.RowDefinitions>
<RowDefinition Height="524" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" Margin="0,0,0,2" >
<RichTextBlock IsTextSelectionEnabled="False" TextAlignment="Left" TextIndent="0" FontSize="14" FontFamily="Segoe WP" >
</RichTextBlock>
</ScrollViewer>
</Grid>
The GridRowDefinition has a fixed hight, because the text in the RichTextBlock needs to be scrolled.
I have prepared a sample project that can be found here. The zip file contains also a screenshot showing how I see the dialog.
I had the same problem and I have solved it by modifying/removing Height/Width and Margins of the Contentdialog

ListPicker only shows first item?

I'm using the Windows Phone Toolkit (latest version installed via NuGet) to create a ListPicker on my Windows Phone page. I've defined a simple ListPicker as follows:
<toolkit:ListPicker Name="lstPicker">
<toolkit:ListPickerItem Content="First Item" />
<toolkit:ListPickerItem Content="Second Item" />
<toolkit:ListPickerItem Content="Third Item" />
</toolkit:ListPicker>
But when I run the app all I see is the first item. Having searched around I can see this is an old bug from 2011 (only the first listpicker opens windows phone) but as I installed from Nuget I should have the latest version. I've also tried downloading the source from CodePlex and referencing a local build but I get the same problem.
This is a Windows Phone 7.1 application so I'm referencing the WP7 assembly.
Anyone know what might cause this in an application?
Thanks
Take a look at the ListPickerMode property.
Normal (this is the default value) - only the selected item is visible on the original pag.
Expanded - all items are visible on the original page.
Full -all items are visible in a separate Popup.
I tried your xaml and it worked fine for me. I referenced the Aug13 toolkit. Here is my full xaml:
<phone:PhoneApplicationPage
x:Class="ListpickerExpanding.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<toolkit:ListPicker Name="lstPicker">
<toolkit:ListPickerItem Content="First Item" />
<toolkit:ListPickerItem Content="Second Item" />
<toolkit:ListPickerItem Content="Third Item" />
</toolkit:ListPicker>
</Grid>
</Grid>
if you are still having problems, please paste your full xaml here.

Why does Windows 8 Phone Flick Gesture only work on upper half of the screen?

I successfully implemented the flick (aka slide, swipe) gesture on my Windows 8 Phone App following the instructions on this post, but for some reason, it is only recognized on the upper half of the screen.
I tried this with the simulator and on an actual dev device (Nokia Lumia 520) and had the same results.
My app is using ApplicationBar and the flick gesture coincidentally starts to recognize motion where the ApplicationBar flyover ends (at full extension).
The image that listens for Gestures also has a tap event, and that one works fine across the whole image (upper/lower halves of the screen).
Thanks in advance...
EDIT:
Here is some code that I tried by creating a blank Page and still not having any luck. The area where the "FLICK" gesture is recognized is constrained to the upper left of the phone screen (both in the simnulator and actual device).
Here is my code (CS):
FlickTest.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace Windows_8_Phone_App
{
public partial class FlickTest : PhoneApplicationPage
{
public FlickTest()
{
InitializeComponent();
}
private void image_GestureListener_Flick(object sender, FlickGestureEventArgs e)
{
if (titulo.Text == "Foo")
{
titulo.Text = "Bar";
}
else {
titulo.Text = "Foo";
}
}
}
}
And the XAML code:
<phone:PhoneApplicationPage
x:Class="Windows_8_Phone_App.FlickTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Landscape" Orientation="Landscape"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="titulo" Text="page name" Margin="9,-7,0,0" />
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Image x:Name="imagen" HorizontalAlignment="Left" Height="309" Margin="10,0,0,0" VerticalAlignment="Top" Width="694" Source="/Assets/AppBar/basecircle.png" Stretch="Fill">
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="image_GestureListener_Flick" />
</toolkit:GestureService.GestureListener>
</Image>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
After much pain, the problem is that the Windows Phone Toolkit has a known issue and it doesn't work in landscape mode (see this entry).
So in the mean time, while that gets fixed, I am looking for alternatives...
Just encountered this problem. GestureListener does not work in landscape mode (as alejandrormz wrote). :(
But, I have a solution -> built in Manipulation and Gesture event. :)
Its easy to implement. Best sample code: GitHub
Hope this helps.

how to set the scroll position on top of silverlight Page

I am Using silverlight4 I have developed one page when I navigate to this page from Other Silverlight Page the Position is at the bottom of the page .I need to set the Focus on top of the silverlight Page.I am not using ScrollViewer on my Page.
Open MainPage.xaml file and replace the code with the following.
<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="ScrollViewerControl.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<ScrollViewer Height="300" Width="300" Name="scrollViewer1"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<ScrollViewer.Content>
<StackPanel>
' Content Here
</StackPanel>
</ScrollViewer.Content>
</ScrollViewer>
</Grid>
</UserControl>
set the ScollViewer offset to zero like
scrollViewer1.ScrollToVerticalOffset(0);
then your vertical scroll will always be on Top.

WP7 usercontrol - change control width when orientation changes

In one of my apps I have a usercontrol called FeedControl (yep, it's yet another RSS reader!) which is very simple - just a checkbox to select the item, a textblock to show the feed name and another textblock to show the number of unread feed items. On loading the feeds into an observable collection at startup I then create one instance of the control for each feed and add them all to a listbox - pretty simple stuff really.
XAML code is below:
<UserControl x:Class="MyReader.FeedControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
Loaded="UserControl_Loaded" >
<Grid x:Name="LayoutRoot" Height="50" Background="Black" HorizontalAlignment="Left" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="70"/>
</Grid.ColumnDefinitions>
<CheckBox Name="Select" Grid.Column="0" IsChecked="{Binding IsSelected}" Margin="-5,-16" Checked="Select_Checked" Background="White"/>
<TextBlock Name="FeedName" Grid.Column="1" Text="{Binding FeedName}" Opacity="1" Margin="-20" VerticalAlignment="Center" FontSize="24"
MouseLeftButtonUp="FeedName_MouseLeftButtonUp" Height="32" Width="360"/>
<TextBlock Name="UnreadItems" Grid.Column="2" Text="{Binding UnreadItems}" Opacity="1" Padding="2" VerticalAlignment="Center" HorizontalAlignment="Right"
FontSize="24" MouseLeftButtonUp="FeedName_MouseLeftButtonUp" />
</Grid>
When the orientation changes of the page the listbox of Feedcontrol items is on I want the feed name textblock to change to the correct size (560px for landscape, 360px for portrait) so I assumed by setting the grid column width to "*" or "Auto" and setting no width for the textblock it would automatically resize but it only resizes to the width of it's text and not the full width.
So then I tried setting the textblock to the default portrait size (360) in the XAML and on the page orientation change event I call the following Method in each instance of the FeedControl currently in the ListBox:
public void ChangeOrientation(bool isLandscape)
{
if (isLandscape)
{
this.LayoutRoot.Width = App.LandscapeWidth; //700
this.FeedName.Width = App.LandscapeItemWidth; //560
}
else
{
this.LayoutRoot.Width = App.PortraitWidth; //480
this.FeedName.Width = App.PortraitItemWidth; //360
}
this.InvalidateArrange();
this.InvalidateMeasure();
}
However, this doesn't work either (no matter what I try) so I am confused about how best to do this... I know there must be a really simple way but so far I've not found it.
Can anybody point me in the right direction please?
Mike
PS sorry for the length of the post... so long for such a simple problem!!
You should set the HorizontalAlignment and HorizontalContentAlignment to HorizontalAlignment.Stretchfor the ListBoxItems which have your control. In addition, set the design width/design height of your control.
Here's an example of one of my controls I have in a listbox, that stretches in landscape mode.
<UserControl x:Class="SabWatch.Resources.Controls.ProgressBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Style="{StaticResource AppBackgroundStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
</Grid>
</UserControl>
And here's an example of setting the alignment properties in code. you can also do this in XAML (and possibly using a style and giving the ListBox a ItemContainerStyle)
var lbi = new ListBoxItem();
var box = new ProgressBox();
...
lbi.Tag = queueObject;
lbi.Content = box;
lbi.HorizontalAlignment = HorizontalAlignment.Stretch;
lbi.HorizontalContentAlignment = HorizontalAlignment.Stretch;
Where u are placing this control, that you are not mentioned . I think u are placing this control inside a Phone page ; like placing any other control. If so better u manage orientation related stuffs in that page( Container page ) instead of making adjustment in the control. I Think this will solve your issue.