E.newelement和Control之间的区别?

发布于 2025-02-11 09:32:12 字数 452 浏览 0 评论 0原文

想为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然 2025-02-18 09:32:12
  • 控制this.control)是平台控件。例如,在Android上,它是android.views.views.view的子类。
  • elementthis.element)是指Xamarin形式的跨平台元素/视图。它是xamarin.forms.view的子类。
  • e.newelement始终与this.Element相同。
  • e.oldelement是此自定义渲染器附加的先前值。当创建渲染器时,它将是null
  • 当渲染器处置时,onelementChanged可以再次调用,e.oldelement是即将消失的XF元素。在这种情况下,e.NewElementnull

重要:在中,onelementChanged始终检查e.NewElement is null。 (或在“走开”/处置时需要做任何“清理”代码,如果您需要做某事。)

  • Control (this.Control) is the PLATFORM control. E.g. on Android, it is a subclass of Android.Views.View.
  • Element (this.Element) refers to the XAMARIN FORMS cross-platform element/view. It is a subclass of Xamarin.Forms.View.
  • e.NewElement is always identical to this.Element.
  • e.OldElement is the previous value that was attached to this custom renderer. It will be null when the renderer is created.
  • When the renderer is disposed, OnElementChanged might be called again, with e.OldElement being the XF element that is going away. In this case, e.NewElement is null.

IMPORTANT: In OnElementChanged, always check whether e.NewElement is null. If it is, do nothing. (Or call any "cleanup" code, if you need to do something when "going away"/disposing.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文