E.newelement和Control之间的区别?
想为xamarin.forms.forms.pooks.pookers.s.pookers.s.pookers.s.pooks.s.pooks.s.pooks.spicks.spicks.spicks.spicks.spicks.s.pookers.s.pooks.spicks.spicks.spicks.spicks.spicks.spickersont。
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
因此,在制作自定义渲染器时,您可以在Overriden onelementChanged()函数中进行大部分工作。我 第二个似乎是从ViewRenderer继承的(在我的情况下是Pickerrenderer)。我也不完全了解E.Oldelement的作用,也许是对我上一个自定义选择器的引用?谢谢。
So when making a custom renderer , you do most of your work inside the overriden OnElementChanged() function.I want to make a custom renderer for the Xamarin.Forms.Picker control:
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
what is here the difference between e.NewElement and Control?The second one seems to be inherited from ViewRenderer(PickerRenderer in my case).I also don't quite understand what e.OldElement does, maybe the reference to my last custom Picker? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
控制
(this.control
)是平台控件。例如,在Android上,它是android.views.views.view
的子类。element
(this.element
)是指Xamarin形式的跨平台元素/视图。它是xamarin.forms.view
的子类。e.newelement
始终与this.Element
相同。e.oldelement
是此自定义渲染器附加的先前值。当创建渲染器时,它将是null
。onelementChanged
可以再次调用,e.oldelement
是即将消失的XF元素。在这种情况下,e.NewElement
是null
。重要:在
中,onelementChanged
,始终检查e.NewElement
isnull
。。 (或在“走开”/处置时需要做任何“清理”代码,如果您需要做某事。)Control
(this.Control
) is the PLATFORM control. E.g. on Android, it is a subclass ofAndroid.Views.View
.Element
(this.Element
) refers to the XAMARIN FORMS cross-platform element/view. It is a subclass ofXamarin.Forms.View
.e.NewElement
is always identical tothis.Element
.e.OldElement
is the previous value that was attached to this custom renderer. It will benull
when the renderer is created.OnElementChanged
might be called again, withe.OldElement
being the XF element that is going away. In this case,e.NewElement
isnull
.IMPORTANT: In
OnElementChanged
, always check whethere.NewElement
isnull
. If it is, do nothing. (Or call any "cleanup" code, if you need to do something when "going away"/disposing.)