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

ItemTemplateSelector with a command on Page

1 Answer 36 Views
ListView
This is a migrated thread and some comments may be shown as answers.
IanV
Top achievements
Rank 1
Veteran
IanV asked on 01 Feb 2019, 06:14 PM

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}"

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 01 Feb 2019, 10:58 PM
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
Tags
ListView
Asked by
IanV
Top achievements
Rank 1
Veteran
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or