【发布时间】:2019-03-06 12:21:12
【问题描述】:
我的列表视图中有一个开关。在 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.
【问题讨论】:
-
你没有实现 convertback 方法,所以你会得到一个 NotImplementedException 是正常的。
-
你显式地抛出了一个 NotImplementedException,所以你当然会得到一个 NotImplementedException。它正在做你告诉它做的事情。
标签: xamarin.forms uiswitch notimplementedexception