This is a migrated thread and some comments may be shown as answers.

DataGrid LoadOnDemandRowTemplate

1 Answer 45 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
BAHADIR KORKUT
Top achievements
Rank 1
BAHADIR KORKUT asked on 24 Apr 2019, 01:22 PM

I want to show total number of elements and number of currently loaded elements in the text property of a label which is inside the DataTemplate of LoadOnDemandRowTemplate.

Setting up Text={Binding ViewModel.TotalNumberOfProducts } for the Label does't seem to work as BindingContext of the LoadOnDemandRowTemplate seems different from the pages's binding context. I couldn't figure out the correct way of implementing this with binding. Can you help?

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 24 Apr 2019, 08:26 PM
Hello Bahadir,

Correct, the BindingContect of the rendered DataTemplate is not the same as the parent. You can use one of two general Xamarin.Forms development options to get access to t value outside of the template's context:

- Source binding

<ContentPage x:Name="Page" ...>
  
  <DataTemplate>
    <!-- This is not in the same BindingContext of the Page, so we use an x:Reference to associate-->
    <Label Text="{Binding BindingContext.TotalNumberOfProducts, Source={x:Reference Page}"  />
  </DataTemplate>
  
</ContentPage>


- Use a static helper class

<ContentPage x:Name="Page" ...>
  
  <DataTemplate>
    <!-- This is not in the same BindingContext of the Page, so we use an x:Reference to associate-->
    <Label Text="{x:Static local:HelperClass.TotalNumberOfProducts}"  />
  </DataTemplate>
  
</ContentPage>

If you have any further trouble, don't hesitate to open a support ticket and share the rest of the code. The UI for Xamarin engineering team will be able to directly investigate.

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataGrid
Asked by
BAHADIR KORKUT
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or