Allow us to set generic type to x:DataType
. Currently, when I try to set x:DataType="pages:IBasePage(x:String)"
, it produces a build error
"pages:IBasePage(x:String) not found"
. Note that this error occurs ONLY when you try to bind to a property from IBasePage. If there is no such Binding, then app compiles without an error.
@viktorszekeress Generics on DataTypes isn't something that's normally supported by XAML so I'm not sure if this one will get implemented.
For now you can inherit from the Type with generics or use a Markup Extension
I'll move this over to our enhancements board and if it gets enough traction we can consider it
@PureWeen I see you mention use a markup extension. I can't quite see how to use a markup extension to solve this problem.
Could you shed a bit of light on that solution?
Any updates?
@JKennedy24 Hei! I think this link could help you to understand why this is needed: https://devblogs.microsoft.com/xamarin/compiled-bindings-xamarin-forms/ If I understood you and the topic starter correctly
I discovered I need support for this as well; I have a utility class Selectable<T>
which allows any object to become "selectable" for UI purposes. If I want to use this in a DataTemplate
, I currently have to forego the use of compiled bindings and deal with ReSharper's "Cannot resolve symbol" errors and the lack of IntelliSense in the Bindings. Putting
x:DataType="{x:Type utility:Selectable(models:MyModel)}"
on my DataTemplate does not cause any syntax errors (and fixes IntelliSense and ReSharper), but the build fails with an "Invalid type" error. The bindings themselves do work, I just can't get IntelliSense for them and ReSharper complains that they're invalid.
Most helpful comment
I discovered I need support for this as well; I have a utility class
Selectable<T>
which allows any object to become "selectable" for UI purposes. If I want to use this in aDataTemplate
, I currently have to forego the use of compiled bindings and deal with ReSharper's "Cannot resolve symbol" errors and the lack of IntelliSense in the Bindings. Puttingon my DataTemplate does not cause any syntax errors (and fixes IntelliSense and ReSharper), but the build fails with an "Invalid type" error. The bindings themselves do work, I just can't get IntelliSense for them and ReSharper complains that they're invalid.