【发布时间】:2018-10-30 09:31:06
【问题描述】:
这是我现在拥有的:
我有这个针对问题进行了简化的模板:
<?xml version="1.0" encoding="UTF-8"?>
<Frame xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:t="clr-namespace:Japanese.Templates"
xmlns:local="clr-namespace:Japanese;assembly=Japanese"
x:Class="Japanese.Templates.RoundButtonText" x:Name="this">
<Label Text="ABC"
TextColor="{Binding LabelTextColor, Source={x:Reference this}}"
/>
</Frame>
还有这个 C#
using Xamarin.Forms;
namespace Japanese.Templates
{
public partial class RoundButtonText : BaseFrameButtonTemplate
{
public RoundButtonText()
{
InitializeComponent();
// I would like to put the Label TextColor binding here instead of in the XAML
}
}
}
谁能帮助我,告诉我如何在 C# 后端添加标签 TextColor 的绑定,以便它以与当前编写时完全相同的方式更改:
TextColor="{Binding LabelTextColor, Source={x:Reference this}}"
在 XAML 中?
【问题讨论】:
-
您想从模板外部绑定颜色吗?
-
BaseFrameButtonTemplate是ControlTemplate的子类吗?
标签: xamarin xamarin.forms