dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

Support compiled bindings for generic ViewModels #20616

Closed StepKie closed 9 months ago

StepKie commented 9 months ago

Please support compiled bindings for ViewModels based on a generic type.

Sample:

In Xaml, I want to bind

x:DataType="viewmodels:MyViewModel(models:MyModel)"

Originally posted by @StephaneDelcroix in https://github.com/dotnet/maui/issues/20568#issuecomment-1946295454

@StephaneDelcroix, according to your offer, should I create an issue for this now, and tag-mention you? Just want to make sure before doing so that this is a real issue and I am not doing something obvious wrong with x:DataType="viewmodels:BoViewModel(models:BoArticle)"

@Hottemax please do

There was a similar request in the Xamarin.Forms github: https://github.com/xamarin/Xamarin.Forms/issues/7161

StephaneDelcroix commented 9 months ago

we would need to support this syntax for x:Type as well.

currently, we're using the type as a string, but we should use the TypeArgumentsParser we already use elsewhere