ListPicker only shows first item? - xaml

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.

Related

Differences between emulator layout and phone layout

I have a problem, because I can't understand why the layout of my app is different when I run it on my phone. The buttons are moved a bit to the right. Screenshot at the link:
On emulator it looks correctly, the items are centered. I'm using Visual Studio Express.
<Page
x:Class="App6.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App6"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid HorizontalAlignment="Right" Margin="0,0.333,0,-0.333" Width="400">
<Grid.RowDefinitions>
<RowDefinition Height="59*"/>
<RowDefinition Height="625*"/>
</Grid.RowDefinitions>
<Button Content="Kliknij" HorizontalAlignment="Center" Click="Button_Click" RenderTransformOrigin="0.585,-5.095" Margin="146,499.253,145,69" Grid.Row="1" />
<TextBlock x:Name="costam" Margin="96,202.253,102,0" TextWrapping="Wrap" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" FontSize="36" HorizontalAlignment="Center" Width="202" Text="kj." Grid.Row="1"/>
<Button x:Name="schowaj" Content="Schowaj" HorizontalAlignment="Left" Margin="139,410.253,0,0" VerticalAlignment="Top" Click="schowaj_Click" Grid.Row="1"/>
<TextBox x:Name="wpisz" HorizontalAlignment="Left" Margin="139,297.253,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="109" Grid.Row="1"/>
<Button x:Name="zamien" Content="Zamień" HorizontalAlignment="Left" Margin="139,351.253,0,0" VerticalAlignment="Top" Click="zamien_Click" Grid.Row="1"/>
</Grid>
The emulator you use probably has a different resolution or screen size that your device. The main problem is you are using margins to position your element, which is totally wrong and resolution/screen size dependent. Just us a Grid and split it into a few rows.

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

XamlParseException: Cannot find a Resource with the Name/Key PhoneBackgroundBrush [Line: 47 Position: 111]

When I first started developing everything was fine but then started up the project for the second time got this error. Since there is an error in the xaml the preview of the design layout never shows so I'm working blindly here.
Did some research, where this individual had the exact problem as me but I tried their solution but it didn't work for me maybe because they were working with Windows Phone 7.1 and Im working with 8. Here's the link: VS Developer Express for Windows Phone new project shows XamlParseException
Any help would be greatly appreciated!
MainPage.xaml:
<phone:PhoneApplicationPage
x:Class="PetSounds.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"
mc:Ignorable="d"
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 Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<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">
<Button Name="PlayAudioButton"
Height="200"
Width="200"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Red"
Click="PlayAudioButton_Click_1">Quack</Button>
<MediaElement x:Name="QuackMediaElement"
Source="/Assets/Audio/Animals/Duck.wav"
Volume="1"
AutoPlay="False"
/>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
EDIT
Here is the App.Xaml file:
<Application
x:Class="PetSounds.App"
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">
<!--Application Resources-->
<Application.Resources>
<local:LocalizedStrings xmlns:local="clr-namespace:PetSounds" x:Key="LocalizedStrings"/>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>
</Application>
If needed let me know and I will post the other files.

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

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.

Page Layout in a silverlight Prism project

OK, I've tried asking this question here, but with not much success. Tried a few hacks like this one; Correct me if I am wrong but I don't think that is the best way.
What I am trying to do is get the silverlight application to span the entire browser area. The solution provided in my previous question works for a standard silverlight project, but for a silverlight Prism project somehow the same rules don't seem to apply. I think that has something to do with the silverlight module containing the page which has the main user control loading within the Content control of the Shell.xaml.
Does anyone know how to fix this?
The code of my Shell.xaml below:
<UserControl x:Class="MyNamspace.Shell"
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"
xmlns:Regions="http://www.codeplex.com/prism"
Background="#FF2D8543"
>
<ContentControl Regions:RegionManager.RegionName="MainRegion"
Background="Black"
VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
>
</ContentControl>
The xaml of my Modulepage which I register within the Contentcontrol of the Shell.xaml
<UserControl x:Class="MyNamspace.MyClass"
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"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
MinHeight="800" MinWidth="800"
>
<UserControl.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF2D8543" Offset="1"/>
</LinearGradientBrush>
</UserControl.Background>
<Grid x:Name="LayoutRoot" Background="#FFEB0A0A"
VerticalAlignment="Top" HorizontalAlignment="Center"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sdk:Label Height="23" HorizontalAlignment="Left" Margin="64,85,0,0" Name="label1"
VerticalAlignment="Top" Width="252" Content="Login page here" />
</Grid>
The reason I am using different colors is because I want to see where the Shell's usercontrol is and where within it is the Contentcontrol. Same goes for my module's page.
Thanks again...
Remove VerticalAlignment and HorizontalAlignment assignments from LayoutRoot.