【问题标题】:Windows phone7 ListPickerWindows phone7 列表选择器
【发布时间】:2012-05-15 13:30:00
【问题描述】:

在我的 windows phone7 应用程序中,我必须使用类似于下拉列表控件的控件。所以我遇到了提供 WP7 工具包程序集的 ListPicker。

我遇到的问题是,它与页面中的其他元素重叠。以下是界面截图。

当我单击 ListPicker 时,它会展开列表并允许我从中选择一项。但是当我选择一个项目时,它会单击出现在该项目下方的按钮。我可以做ExpansionMode="FullScreenOnly",但它会进入全屏模式,因为列表选择器只有 3 个项目,这不是我想要的方式。

有谁知道我可以让 ListPicker 展开并从中选择一个而不会单击位于其下方的按钮的任何方法。

编辑

我已安装 WP7 Tool kit for Silverlight 并将 dll 作为参考添加到项目中 Microsoft.Phone.Controls.Toolkit

XAML--->

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"


<toolkit:ListPicker Name="listPicker1"/>

【问题讨论】:

  • 嗨,谢谢保罗。我刚刚添加了 XAML 部分。在页面加载中为 ListPiclker 提供 ItemSource 作为列表(List country)[listPicker1.ItemsSource = country;]

标签: windows silverlight windows-phone-7 silverlight-4.0 windows-phone-7.1


【解决方案1】:

我怀疑您正在使用 Canvas 来布局控件。如果您使用 Grid,则 ListPicker 将与您放置在其下方的任何其他控件一起正常工作(在列表展开时自动移动其下方的控件):-

        <Grid x:Name="ContentPanel"
          Grid.Row="1"
          Margin="12,0,12,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <toolkit:ListPicker x:Name="MyListPicker"
                            Grid.Row="0">
            <toolkit:ListPicker.Items>
                <toolkit:ListPickerItem Content="item1" />
                <toolkit:ListPickerItem Content="item2" />
                <toolkit:ListPickerItem Content="item3" />
            </toolkit:ListPicker.Items>
        </toolkit:ListPicker>
        <Button x:Name="MyButton"
                Content="Check availability"
                Click="MyButton_Click" Grid.Row="1"/>
    </Grid>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多