Xamarin 如何创建接受颜色字符串的模板绑定?
我使用的模板如下:Xamarin 如何创建接受颜色字符串的模板绑定?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我使用的模板如下: 您不需要使用转换器,Xamarin Forms默认接受字符串作为颜色,您只需这样使用:“#XXXXXX”。您只需传递“#FF0000”,它就会被接受。您不需要使用转换器,Xamarin Forms默认接受字符串作为颜色,您只需这样使用:“#XXXXXX”。你只要通过“#FF0000”就可以了 <template:ButtonTemplate ButtonType="2" Grid.Column="0" Text="{Binding FBtnText}" L
您不需要使用转换器,Xamarin Forms默认接受字符串作为颜色,您只需这样使用:“#XXXXXX”。您只需传递“#FF0000”,它就会被接受。您不需要使用转换器,Xamarin Forms默认接受字符串作为颜色,您只需这样使用:“#XXXXXX”。你只要通过“#FF0000”就可以了
<template:ButtonTemplate ButtonType="2" Grid.Column="0" Text="{Binding FBtnText}"
LabelTextColor="{Binding FBtnLabelTextColor, Converter={StaticResource StringToColorConverter}"
TapCommand="{Binding FBtnCmd }" />
public static readonly BindableProperty LabelTextColorProperty =
BindableProperty.Create(
nameof(LabelTextColor),
typeof(Color),
typeof(ButtonTemplate),
Color.FromHex("C9C9C9"));
public Color LabelTextColor
{
get { return (Color)GetValue(LabelTextColorProperty); }
set { SetValue(LabelTextColorProperty, value); }
}