我创建的控件没有IsChecked属性,所以我创建了它,但当我试图绑定到它时,我收到了此错误。您能告诉我错误在哪里吗?
<Ctrl:CtrlImageToggleButton
x:Name="xEnablePV"
Grid.Row="7"
Grid.Column="1"
HorizontalOptions="Start"
IsChecked="{Binding EnablePV}"
ToggleOffImageSource="btn_off.png"
ToggleOnImageSource="btn_on.png" />
public class CtrlImageToggleButton : ImageButton
{
private bool bCheck = false;
public delegate void eStatusChanged();
public event eStatusChanged event_StatusChanged;
public bool IsChecked
{
get
{
return bCheck;
}
set
{
bCheck = value;
SetValue(IsCheckedProPerty, value);
if (this.event_StatusChanged != null)
{
this.event_StatusChanged();
}
}
}
public static readonly BindableProperty IsCheckedProPerty = BindableProperty.Create(
propertyName: "IsCheckedProPerty",
returnType: typeof(bool),
declaringType: typeof(CtrlImageToggleButton),
defaultValue: false,
defaultBindingMode: BindingMode.TwoWay,
propertyChanged: IsCheckedProPertyChanged);
private static void IsCheckedProPertyChanged(BindableObject bindable, object oldValue, object newValue)
{
(bindable as CtrlImageToggleButton).IsChecked = (bool)newValue;
}
}
}
XFC0009找不到“IsChecked”的属性、BindableProperty或事件,或值和属性之间的类型不匹配。POP D:\ProgramSrc\POP Renewal\POP\POP\Component\Spectrum\Spectrum_OptionPage.xaml 196
1条答案
按热度按时间cgh8pdjw1#
对于Bindable属性,有一个固定的命名约定,您必须遵循该约定,因此您的属性名称应该如下所示:
祝你好运!