【问题标题】:Xamarin: Bind one to another property in StyleXamarin:将一个绑定到样式中的另一个属性
【发布时间】:2018-11-27 16:07:19
【问题描述】:

我想将属性 WidthRequest 绑定到 HeightRequest。

<Style TargetType="Frame" >
    <Setter Property="HeightRequest" Value="200"/>
    <Setter Property="WidthRequest" Value="{Binding HeightRequest}"/>
</Style>

所以 WidthRequest 的值应该是 200

谢谢你:)

【问题讨论】:

  • Setter 类没有可绑定的属性,只有当HeightRequest 被绑定并且是动态值而不是静态值时,按照您的建议进行操作才有意义,但您不能绑定这些属性,所以这是一个非首发。也许如果你解释你想要的最终结果是什么,有人可以提出实现它的方法。

标签: c# xamarin binding


【解决方案1】:

也许在后面的代码中这样做

public int HeightRequest { get; set; }

public int WidthRequest
{
    get
    {
        return HeightRequest;
    }
}

【讨论】:

  • 不,我想在样式部分执行此操作。也许我必须告诉样式,DataContext 是自己的属性?
猜你喜欢
  • 1970-01-01
  • 2010-11-14
  • 1970-01-01
  • 2018-04-01
  • 1970-01-01
  • 2013-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多