【问题标题】:How to create a template variable like that of Angular 2?如何创建像 Angular 2 那样的模板变量?
【发布时间】:2018-01-17 04:50:46
【问题描述】:

我想在 Xamarin Forms 中创建一个模板变量,就像我们可以在 Angular 中创建的那样。

比如this

【问题讨论】:

    标签: xamarin xamarin.forms template-variables


    【解决方案1】:

    您可以使用 x:Name 来命名视图,然后使用 x:Reference 在其他地方引用它。像下面这样:

    <Slider x:Name="slider"
            Maximum="360" />
    
    <Label BindingContext="{x:Reference slider}"
          Text="{Binding Value, StringFormat='The angle is {0:F0} degrees'}" />
    

    Here is an article 展示了这种和其他绑定技术。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-27
      • 2017-04-27
      • 2023-03-29
      • 2017-06-11
      • 2017-05-19
      • 1970-01-01
      • 1970-01-01
      • 2017-09-29
      相关资源
      最近更新 更多