dotMorten / MauiEx

A set of .NET MAUI controls
Apache License 2.0
224 stars 55 forks source link

Allow extending for additional platforms #63

Closed domyd closed 4 years ago

domyd commented 4 years ago

Hi,

I've now gotten around to creating an extension package out of my WPF implementation (#45). However, I'm stuck at raising the three events of the AutoSuggestBox ...

public event EventHandler<AutoSuggestBoxSuggestionChosenEventArgs> SuggestionChosen;
public event EventHandler<AutoSuggestBoxTextChangedEventArgs> TextChanged;
public event EventHandler<AutoSuggestBoxQuerySubmittedEventArgs> QuerySubmitted;

... as the methods that would allow me to do so (RaiseSuggestionChosen, NativeControlTextChanged and RaiseQuerySubmitted) are internal.

The easiest way to allow this, of course, would be to make these methods public. And that would work. But I'm not sure it's the best way to go about doing that, and I can't really think of another way to solve this off the top of my head.

Thoughts?

dotMorten commented 4 years ago

The proper way to do this would be by using the MessagingCenter instead of internal methods. I didn't know about that when I wrote the renderers, so in hindsight I should go back and fix it.

I agree that making it public isn't the way to go about it

dotMorten commented 4 years ago

@domyd Could you try the branch above and see if that solves your problem? You can see here how you'd raise the events using the messaging center: https://github.com/dotMorten/XamarinFormsControls/blob/Messaging/AutoSuggestBox/Platform/AutoSuggestBoxRenderer.cs#L148-L161

I'd probably merge this if it checks out in testing (gimme a few days)

domyd commented 4 years ago

That works for me 👍

Would you mind if I use dotMorten.Xamarin.Forms.AutoSuggestBox.WPF as the package name and namespace? I figure that would make it clearer to users that those two are related. But it's totally fine if you're not comfortable with that.

dotMorten commented 4 years ago

@domyd The reason I use that prefix is to clearly state ownership, so I'd prefer you do not use that. I'd be more than happy to refer to your package in the readme, as well as in the nuget package description.

dotMorten commented 4 years ago

PR Merged

dotMorten commented 4 years ago

@domyd Just pushed v1.1.0