ItemTemplateSelector with a command on Page

2 posts, 0 answers
  1. IanV
    IanV avatar
    39 posts
    Member since:
    Dec 2008

    Posted 01 Feb 2019 Link to this post

    I have a telerikDataControls:RadListView.ItemTemplateSelector working nicely. 

    <telerikDataControls:RadListView.ItemTemplateSelector>
        <vm:TodayCellSelector
            AllDayTemplate="{StaticResource AllDayCellTemplate}"
            InspirationTemplate="{StaticResource InspirationCellTemplate}"
            ErrorTemplate="{StaticResource ErrorCellTemplate}">

     

    The templates are in separate files like this:

    <?xml version="1.0" encoding="utf-8"?>
    <?xaml-comp compile="true" ?>
    <ResourceDictionary
        xmlns:telerikListView="clr-namespace:Telerik.XamarinForms.DataControls.ListView;assembly=Telerik.XamarinForms.DataControls"
        <DataTemplate  x:Key="ErrorCellTemplate">
            <telerikListView:ListViewTemplateCell>
                <telerikListView:ListViewTemplateCell.View>
                    <Label Text="ERROR"></Label>
                </telerikListView:ListViewTemplateCell.View>
            </telerikListView:ListViewTemplateCell>
        </DataTemplate>
    </ResourceDictionary>

     

    Problem: I need to call an ICommand on the parent Page from the Cell. How do I reference the page? I tried to give the page a x:Name and try that in the Binding on the Cell, but the compiler throws an error that it can't find the Page.

    The cell, if placed in the main page works fine, but the cells are huge so I want them in separate files to manage.

    TappedCommand="{Binding Source={x:Reference MyPage}, Path=BindingContext.EventDetailCommand}"

     

     

     

     

     

  2. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1193 posts

    Posted 01 Feb 2019 Link to this post

    Hi Ivan,

    The Xamarin.Forms framework does not support this. You'll need either need to to redesign the approach so that the x:Reference is available in scope of the ContentPage, or place the Resources area below the content area (so that it is out of your way).

    For example:

    <ContentPage>
        <Grid>
            ...your content
        </Grid>
     
        <ContentPage.Resources>
            ... your resources
        </ContentPage.Resources>
    </ContentPage>


    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
Back to Top