Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Type mismatch on Bindableproperty

$
0
0

Hi,

I have following codes in my custom view class and xaml files:

my custom property:

public static readonly BindableProperty LabelColorProperty = BindableProperty.CreateAttached("LabelColor", typeof(Color), typeof(InfoCell), Color.White, 
    propertyChanged: HandleLabelColorChange);

public static Color GetLabelColor(BindableObject target) {
    return (Color)target.GetValue(LabelColorProperty);
}

public static void SetLabelColor(BindableObject target, Color value) {
    target.SetValue(LabelColorProperty, value);
}

private static void HandleLabelColorChange(BindableObject bindable, object oldValue, object newValue){
    //here i do stuff
}

my xaml tag:
<ce:InfoCell DescriptionText="{Binding DetailCount}" LabelColor="{StaticResource primaryTextColor}"/>

my static resource in App.xaml
<Color x:Key="primaryTextColor">White</Color>

When i pass a color property to LabelColor like White, Black etc. everything is ok. But when i pass a static resource like above
a compile time error occurs like
No property, bindable property, or event found for 'LabelColor', or mismatching type between value and property...

So, what am i missing?

Thanks in advence..


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>