【问题标题】:TemplateBinding in Xamarin.Froms not workingXamarin.Froms 中的 TemplateBinding 不起作用
【发布时间】:2018-01-04 09:26:07
【问题描述】:

我从 Xamarin 官方页面尝试了this simple example,其中包含一个模板绑定,例如:

<ControlTemplate x:Key="TealTemplate">
  <Grid>
    <Label Text="{TemplateBinding Parent.HeaderText}" />
    <Label Text="{TemplateBinding Parent.FooterText}" />
  </Grid>
</ControlTemplate>

但是,我总是通过将示例代码复制到 Visual Studio 来得到错误。:

谁能给我一个简短的例子,如何从 ControlTemplate 中绑定到模板化控件的属性,无论是绑定上下文还是控件本身?

【问题讨论】:

    标签: xaml xamarin xamarin.forms templatebinding


    【解决方案1】:

    我还没有解决“父母”的问题。但对于我的项目,我使用:

    {TemplateBinding BindingContext.IsBusy}
    

    在使用 ControlTemplate 的页面中,我还使用了一个 ViewModel 并将这个具有 IsBusy 属性的 ViewModel 绑定到页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-09
      • 1970-01-01
      • 1970-01-01
      • 2016-10-28
      相关资源
      最近更新 更多