【问题标题】:ListPicker only shows first item?ListPicker 只显示第一项?
【发布时间】:2014-01-03 08:58:23
【问题描述】:

我正在使用 Windows Phone 工具包(通过 NuGet 安装的最新版本)在我的 Windows Phone 页面上创建一个 ListPicker。我定义了一个简单的 ListPicker 如下:

<toolkit:ListPicker Name="lstPicker">
   <toolkit:ListPickerItem Content="First Item" />
   <toolkit:ListPickerItem Content="Second Item" />
   <toolkit:ListPickerItem Content="Third Item" />
</toolkit:ListPicker>

但是当我运行应用程序时,我看到的只是第一项。经过四处搜索,我可以看到这是 2011 年以来的一个旧错误 (only the first listpicker opens windows phone),但是当我从 Nuget 安装时,我应该拥有最新版本。我也尝试从 CodePlex 下载源代码并引用本地构建,但我遇到了同样的问题。

这是一个 Windows Phone 7.1 应用程序,所以我引用的是 WP7 程序集。

任何人都知道在应用程序中可能导致此问题的原因是什么?

谢谢

【问题讨论】:

    标签: xaml windows-phone-7 windows-phone windows-phone-toolkit


    【解决方案1】:

    查看 ListPickerMode 属性。

    正常(这是默认值) - 只有选定的项目在原始页面上可见。 展开 - 所有项目都在原始页面上可见。 Full - 所有项目在单独的 Popup 中可见。

    我尝试了您的 xaml,它对我来说效果很好。我参考了 Aug13 工具包。这是我的完整 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>
    

    如果仍有问题,请在此处粘贴完整的 xaml。

    【讨论】:

    • 你能粘贴整个xaml吗
    猜你喜欢
    • 2016-09-13
    • 1970-01-01
    • 2021-02-13
    • 1970-01-01
    • 1970-01-01
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多