ListPicker不会在WP7上的StackPanel中扩展

时间:2012-02-13 17:35:41

标签: windows-phone-7 xaml stackpanel listpicker

另一天另一个问题,这次我认为XAML格式化的一个简单问题。

我在WP7应用程序的XAML页面上的StackPanel中有一个ListPicker。每当我点击ListPicker时,它会展开,但它似乎会扩展到它下方的项目后面。如果我在列表中有足够的项目,它将以全屏模式打开,工作正常。

任何建议,指示都将不胜感激;

<Grid Name="grdBought">

<StackPanel Visibility="Visible" Margin="0,0,0,0" Height="480">
    <Button Name="btnSave" Grid.Row="0" Content="Save" Height="100" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="378" Click="btnSave_Click" />

        <StackPanel Grid.Row="1" Orientation="Vertical">


            <toolkit:ListPicker Name="CategoryPicker" Header="Select Category" HorizontalAlignment="Left" ItemsSource="{Binding Categories}" CacheMode="BitmapCache" TabIndex="0" Margin="0,0,0,0" SelectionChanged="CategoryPicker_SelectionChanged" Height="100" Width="195">
                <toolkit:ListPicker.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical" HorizontalAlignment="Left">
                            <TextBlock Text="{Binding CategoryDesc}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />
                        </StackPanel>
                    </DataTemplate>
                </toolkit:ListPicker.ItemTemplate>

                <toolkit:ListPicker.FullModeItemTemplate>
                    <DataTemplate>
                        <StackPanel Name="item" Orientation="Vertical" Margin="0, 0, 0, 0">
                            <TextBlock Margin="0, 0, 0, 0" Text="{Binding CategoryDesc}" FontSize="40" TextWrapping="Wrap" />
                        </StackPanel>
                    </DataTemplate>
                </toolkit:ListPicker.FullModeItemTemplate>
            </toolkit:ListPicker>


            <StackPanel Name="Items" Grid.Row="1" Orientation="Horizontal">
                <TextBox Name="txtDescription" Height="100" Margin="0,0,0,0" Text="" Width="225" MaxLength="100" FontSize="40" InputScope="Text" />
                <TextBox Name="txtAmount" HorizontalAlignment="Left" Text="0.00" Height="100" Margin="0,0,0,0" TextAlignment="Right" FontSize="40" FontFamily="Segoe WP Semibold" Width="163" KeyUp="txtAmount_KeyUp" />
            </StackPanel>

        </StackPanel>

    <TextBlock Name="tb1" Text="Amount" Height="27" Margin="0,0,0,0" Width="137" />
    <Button Name="button1" Content="Button" Height="72" HorizontalAlignment="Left" Margin="249,0,0,0" VerticalAlignment="Top" Width="160" Click="button1_Click" />

</StackPanel>

我已经浏览过windowsphonegeek.com网站上的示例,但我仍然无法使其正常工作!

2 个答案:

答案 0 :(得分:3)

问题在于您将ListPicker的高度设置为100.删除它,然后保留为自动。当你限制高度时,这是一个问题b / c,listpicker无处可扩展(因此,显示你所看到的行为)

答案 1 :(得分:0)

我猜高度正在创建一个问题,只需确保listpicker的高度大于stackpanel。