ComboBox按下它下面的控件

时间:2014-07-23 12:21:13

标签: c# xaml windows-phone-8 combobox windows-phone-8.1

与WP中的任何组合框一样,当组合框打开(展开)时,它会向下推动组合框。 在我的应用程序打开时,其中一些被隐藏,因为另一个控件已经结束了。 打开组合框时,如何使所有控件都关闭。 我想这样做 Right ComboBox

我拥有的是这样的

what i have

- 编辑 我的xaml代码是

<Grid x:Name="addingBabyGrid" HorizontalAlignment="Center" Height="412" VerticalAlignment="Center" Width="323">
            <Grid.Background>
                <SolidColorBrush Color="White" Opacity="0.9"/>
            </Grid.Background>
            <StackPanel Orientation="Vertical">
                <TextBox HorizontalAlignment="Center" Height="41" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" Width="303"/>
                <ComboBox HorizontalAlignment="Center" Height="53" Width="298" RequestedTheme="Light" Background="Black">
                    <ComboBoxItem Content="Male"/>
                    <ComboBoxItem Content="Female"/>
                </ComboBox>
                <DatePicker Width="293" HorizontalAlignment="Center" Foreground="White" Background="Black" BorderBrush="#FF7E7E7E" RequestedTheme="Light"/>
            </StackPanel>
        </Grid>

1 个答案:

答案 0 :(得分:2)

我认为您应该使用的是Silverlight Toolkit for Windows Phone中的ListPicker,用于您需要的任务。此外,您的问题主要是您已明确设置ComboBox的高度,这不允许它显示其他项目。

请参阅我想要的代码:

<Grid x:Name="addingBabyGrid" HorizontalAlignment="Center" Height="412" VerticalAlignment="Center" Width="323">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <TextBox Grid.Row="0" HorizontalAlignment="Center" Height="41" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" Width="303"/>
    <wpToolkit:ListPicker Grid.Row="1" HorizontalAlignment="Center" Width="298">
        <ComboBoxItem Content="Male"/>
        <ComboBoxItem Content="Female"/>
    </wpToolkit:ListPicker>
    <DatePicker Width="293" HorizontalAlignment="Center" Foreground="White" Background="Black" BorderBrush="#FF7E7E7E" RequestedTheme="Light"/>
</Grid>

通常,在使用StackPanel和Grid等控件时,您不希望设置元素的高度和宽度,而是让它们由容器,控件内容或两者自动设置。