Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Get parent class from DataTemplate

$
0
0

Hi there, i come from a Unity C# background but Xamarin is a bit different regarding Data and Bindings and i have some doubts regarding how to do it.

Description of my problem
Is there any way to obtain the class that is being renderer by a DataTemplate, inside a DataTemplate?, If i'm doing wrong, can you suggest a better way to do this?

PseudoExample of what i'm trying to accomplish

Structure
MyClass.cs
MyClassDataTemplate.cs

Code
public DataTemplate MyClassDataTemplate()
{
return new DataTemplate(() =>
{
MyClass class = this.MyClass.Foo;
return new ViewCell();
}
}

Link i found quite related to this
https: // forums.xamarin.com/discussion/71462/datatemplate-with-templateselector-bind-to-parent-command

Additional Comments
I use pure C# with Xamarin.Forms, i searched a lot of questions and things but a lot are in XAML and i can't find the right answer to be honest.

I can't do new datatemplate every time since Android have a limit of 20 per list view, so adding the variable is not an option.

Thank you in advanced!


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>