我的列表视图中有一个开关。在 xaml 中,为 IsToggled 属性添加了一个转换器:
<Switch
IsToggled="{Binding userProfileTO.userId, Converter={StaticResource isToggledConverter}}"
HorizontalOptions="EndAndExpand"
VerticalOptions="CenterAndExpand"/>
转换器代码:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool toggle = false;
// My Codes
return toggle;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
运行此代码时在 ConvertBack 上获得 NotImplementedException。
Exception thrown: 'System.NotImplementedException' in Myprojectname.dll
An exception of type 'System.NotImplementedException' occurred in Myprojectname.dll but was not handled in user code
The method or operation is not implemented.