Xaml 重置Xamarin fomrs中相对布局中存在的图像的XConstraint和YConstraint

Xaml 重置Xamarin fomrs中相对布局中存在的图像的XConstraint和YConstraint,xaml,xamarin,xamarin.forms,Xaml,Xamarin,Xamarin.forms,我在Xamarin表单中有一个要求,在RelativeLayout中定位的图像需要根据条件进行更改。我只能通过代码得到条件。这是我的密码 <?xml version="1.0" encoding="utf-8" ?><ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x

我在Xamarin表单中有一个要求,在RelativeLayout中定位的图像需要根据条件进行更改。我只能通过代码得到条件。这是我的密码

<?xml version="1.0" encoding="utf-8" ?><ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Test.Views.Home">  <ContentPage.Content>
<RelativeLayout>      
  <ContentView
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
  </ContentView>
  <Image Source="imageButton.png"
                     x:Name="FloatButton"
                     HeightRequest="100"
                     WidthRequest="100"
                     RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-98}"
                     RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-113}"/>
</RelativeLayout>  </ContentPage.Content></ContentPage>

在这里,如果您看到图像控件的RelativeLayout.YConstraint,我需要将表达式更改为

RelativeLayout.YConstraint=“{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=1,常数=-250}”/>


我如何通过代码来实现它?注意,一开始我需要像上面的xaml代码那样设置它,在代码内部的某些条件下,我需要像上面的代码一样更改YConstraint。有人能帮我吗?

如果论坛的链接不够清晰或对你不起作用,请告诉我,我会提供答案,我不需要任何动画和其他内容。我只需要将现有图像的位置更改为RelativeLayout.YConstraint=“{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=1,Constant=-250}”/>。我还尝试了上面的讨论细节,但没有帮助我考虑禁用可以在LayoutTo duration 0中指定的动画。没有其他方法可以通过编程更改约束还有另一个建议“您可以通过视图的setBoundsConstrains方法,然后调用视图的forceLayout方法,从代码中更新约束”我没有尝试过