WP7最大宽度文本框和从右侧设置的位置

时间:2011-12-13 13:14:19

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

我有这段代码:

<controls:PivotItem Header="Hledat">
    <Canvas Margin="0">
        <TextBox  Name="SearchTxb"  Height="72" Text="" VerticalAlignment="Top" HorizontalAlignment="Right" />
        <Button Name="SearchBtn" Margin="0,74,100,0" Width="200" Height="72" Click="SearchBtn_Click" HorizontalAlignment="Right" VerticalAlignment="Top">Hledat</Button>
    </Canvas>
</controls:PivotItem>

我想支持肖像和风景。这应该是用于搜索的pivotitem。我想将文本框的宽度更改为手机屏幕的全尺寸,我想将按钮设置位置设置为f.e. 20从右侧。我应该在代码中添加什么?感谢

1 个答案:

答案 0 :(得分:0)

<controls:PivotItem Header="Hledat">
    <Grid Margin="0">
        <Grid.ColumnDefinition>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinition>
        <TextBox Grid.Column="0"  Name="SearchTxb"  Height="72" Text="" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
        <Button Grid.Column="1" Name="SearchBtn" Margin="0,74,100,0" Width="200" Height="72" Click="SearchBtn_Click" HorizontalAlignment="Right" VerticalAlignment="Top">Hledat</Button>
    </Grid>
</controls:PivotItem>