Xamarin.forms Xamarin表单:获取NotImplementedException
我的列表视图中有一个开关。在xaml中,为IsToggled属性添加的转换器:Xamarin.forms Xamarin表单:获取NotImplementedException,xamarin.forms,uiswitch,notimplementedexception,Xamarin.forms,Uiswitch,Notimplementedexception,我的列表视图中有一个开关。在xaml中,为IsToggled属性添加的转换器: <Switch IsToggled="{Binding userProfileTO.userId, Converter={StaticResource isToggledConverter}}" HorizontalOptions="EndAndExpand" VerticalOptions="CenterAndExpand"/> 运行此代码时
<Switch
IsToggled="{Binding userProfileTO.userId, Converter={StaticResource isToggledConverter}}"
HorizontalOptions="EndAndExpand"
VerticalOptions="CenterAndExpand"/>
运行此代码时在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.
IsToggled
属性的默认绑定类型为“Two-way
”。
这就是调用ConvertBack
函数的原因。
您只需删除
throw new NotImplementedException();
在您的ConvertBack
方法中,一切都会正常工作
或者,如果您不想这样做,您可以显式地将绑定模式设置为
单向
属性的默认绑定类型为“双向
”。
这就是调用ConvertBack
函数的原因。
您只需删除
throw new NotImplementedException();
在您的ConvertBack
方法中,一切都会正常工作
或者,如果您不想这样做,您可以显式地将绑定模式设置为单向您没有实现convertback方法,因此您将得到一个NotImplementedException,这是正常的。您显式地抛出一个NotImplementedException,因此您当然会得到一个NotImplementedException。它完全按照您的要求执行。您没有实现convertback方法,因此您将得到NotImplementedException是正常的。您显式地抛出NotImplementedException,因此您当然会得到NotImplementedException。它正在做你告诉它要做的事情。如果我删除了那个代码,我能给什么来代替它呢?ConvertBack方法应该返回值,返回false就足够了吗?这会使您的代码容易出错,最好切换到单向绑定模式。如果我删除了该代码,我可以用什么来代替它?ConvertBack方法应该返回值,返回false是否足够?这将使代码容易出错,最好切换到单向绑定模式。