如果我想在屏幕上将按钮移动到与页面上另一个控件的高度相同的距离,我可以这样做:
this.myControl.TranslateTo(20, - this.myOtherControl.Height);
在XAML中有没有办法做到这一点?
答案 0 :(得分:0)
您的情况是否类似于下面的屏幕截图?
您要实现此屏幕截图吗?
您可以使用TranslationY="{ Binding Path=TranslationY ,Source={x:Reference btn1}}"
来实现。
<StackLayout Orientation="Horizontal" VerticalOptions="Start">
<StackLayout Orientation="Horizontal" HeightRequest="100" Padding="20,0,0,0">
<Button x:Name="btn1" Text="Aqua" HeightRequest="60" WidthRequest="50" TranslationY="23" />
</StackLayout>
<StackLayout Orientation="Horizontal" HeightRequest="100" Padding="20,0,0,0">
<Button HeightRequest="60" WidthRequest="50" Text="llll" TranslationY="{ Binding Path=TranslationY ,Source={x:Reference btn1}}"/>
</StackLayout>
</StackLayout>