我正在尝试在xaml中的内容视图类中设置/绑定list属性。
这是我的班级:
public class Myclass:ContentView
{
public static readonly BindableProperty TabItemSourceProperty = BindableProperty.Create(
"TabIndicatorItemSource",
typeof(IEnumerable<string>),
typeof(Myclass)
);
public IEnumerable<string> TabIndicatorItemSource {
get
{
return (IEnumerable<string>)GetValue(TabItemSourceProperty);
}
set
{
SetValue(TabItemSourceProperty, value);
}
}}
,这是我在ExampleClass.xaml.cs中的Xaml
local:Myclass x:Name="myCarouselView" TabTextSizeTabIndicatorItemSource ="{Binding tabListSource}"
tabListSource是ExampleClass.cs中的List属性。
但是我遇到了这种类型不匹配的错误。我哪里错了?
答案 0 :(得分:0)
Bindable Properties需要遵守设定的命名约定。例如TabItemSourceProperty与TabItemSource
有关public class Myclass: ContentView
{
public static readonly BindableProperty TabItemSourceProperty = BindableProperty.Create(
"TabItemSource",
typeof(IEnumerable<string>),
typeof(Myclass)
);
public IEnumerable<string> TabItemSource {
get
{
return (IEnumerable<string>)GetValue(TabItemSourceProperty);
}
set
{
SetValue(TabItemSourceProperty, value);
}
}}
与
local:Myclass x:Name="myCarouselView" TabItemSource="{Binding tabListSource}"