锚文本框的左右(所以它伸展时,父大小) [英] Anchor a TextBox to the right and Left (so it’s stretched when parent is resized)

查看:86
本文介绍了锚文本框的左右(所以它伸展时,父大小)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找的XAML等价的WinForms的属性。 我想锚定文本框这是一个画布(在UWP应用程序)的左侧和右侧,使得它一直260从左侧和10从右侧。我试过的许多的东西,但是一个看起来最有希望的是:

I’m looking for the XAML equivalent of Winforms’ Anchor property. I want to anchor a TextBox that’s on a Canvas (on a UWP app) to the left and right so it’s always 260 from the left and 10 from the right. I’ve tried many things, but the one that looks most promising was:

<TextBox Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  TextWrapping="Wrap" Text="TextBox"  Margin="260,10,10,10"/>

有不,但是固定在正确的

It does not, however anchor to the right.

推荐答案

我会用一个 3列 电网

<Grid x:Name="YourOuterGrid">
    <Grid VerticalAlignment="Top">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="160" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="10" />
        </Grid.ColumnDefinitions>
        <TextBox TextWrapping="Wrap" Grid.Column="1" />
    </Grid>
</Grid>

这篇关于锚文本框的左右(所以它伸展时,父大小)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆