LazyView #1030
-
I tried to use ControlTemplate inside LazyView control. Unfortunately, it does not work. Can someone explain what I have to change in class BaseLazyView. Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@Senso4sLab you can't use ControlTemplate with LazyView, you need to pass the view's type. You can take a look at our sample to have a better idea of how to use it. |
Beta Was this translation helpful? Give feedback.
-
I received those questions in my email, so I'll reply to those here to make it more useful for all devs.
Yes, LazyView doesn't support TemplateControl(TC) right now, if we can make it work with TC we can implement this feature.
The LazyView concept wasn't my idea, I took it from this article. I believe that it doesn't implement TC because it can't easily be lazy load. I know that on Shell we can pass a page as ControlTemplate and that will make the page be lazy load, which means, the page will just be allocated when the user navigates to it. But for controls that aren't true (AFAIK), so if you have something like this <ContentPage .../>
<StackLayout>
<Button Text="Load something ruge" Command="{Binding ClickCommand}" />
<LazyView ControlTemplate={local:MyView} />
</StackLayout>
</ContentPage> In that case, the LazyView will be allocated right after the page is allocated. Using the And if you or anyone finds a way to implement a LazyView with TC just open an issue with a spec and send a PR❣
In the article that I provide, you can find another implementation, that you can use as a sample. The short answer will be, just create a class that extends from |
Beta Was this translation helpful? Give feedback.
@Senso4sLab you can't use ControlTemplate with LazyView, you need to pass the view's type. You can take a look at our sample to have a better idea of how to use it.
https://github.com/xamarin/XamarinCommunityToolkit/blob/develop/samples/XCT.Sample/Pages/Views/TabView/LazyTabPage.xaml