English 中文(简体)
Maui Handlers using partial classes do always replace existing handlers? How to customize and existing control with Handlers?
原标题:

I don t really understand Maui handlers using Partial class method. When using other method you have options like AppendToMapping that you can extend the current mapping but when I use partial classes, I get a new instance of the control always. I am not able to append the existing control. That means if i define a control that inherits from Maui control with some default values and registering this control with platforms specific handlers, my control loses predefined cross platform values. This is not the way Renderers are working xamarin.forms? So what is this case and how to fix this?

Please dont suggest me to use Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping because this does not exist in maui class library if i want to work with nuget packages.

Even Microsoft s documentation doesn t mention about partial classes to customize a control but mentions here Create a control. (yes there is something at the end with Partial class but this is totally irrelevant, not sure what is this about and MS documented something like that) Why? If that is not possible, thats a huge downgrade in Maui from Xamarin.forms.

UPDATE:

I have created a test repo with demo maui project and maui class library.

https://github.com/EmilAlipiev/TestMauiHandlers

under the class library you find the Old renderers under each platform and new upgraded Handlers under handlers folders.

  1. So first run the Demo project in IOS without handlers. you can see the default value for text "this is default text" on the ui.
  2. enable ConfigureMauiHandler in MauiProgram.cs in HandlersDemoApp
  3. You see that default text is empty

Reason for that is Handlers are creating a complete new Entry instead of extending the Entry defined in the shared part i believe.

If i use renderers they will be just extended with the default cross platform definitions.

last question; I have this CustomEntry in the Class library because i want to created a nuget package. How do i register handlers within the class library?

问题回答

暂无回答




相关问题
How to customize flyout page top bar in xamarin forms

I want to customize top bar of Xamarin forms like following i want to add some of menus search-bar and profile icon with drop down I am trying to achieve this with flyoutpage control. Please help me ...

热门标签