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

Item swipe template (URGENT)

3 Answers 89 Views
ListView
This is a migrated thread and some comments may be shown as answers.
mo
Top achievements
Rank 1
mo asked on 07 Sep 2017, 07:50 AM

Hello

i want to make item swipe content template in cs file not in xaml 

i tried this 

      MainList.ItemSwipeContentTemplate = new DataTemplate(() =>
            {

                var mainGrid = new Grid { ColumnSpacing = 0, RowSpacing = 0, Padding = 0, Margin = 0 };

                mainGrid.Children.Add(new Label { Text = "Sign"});

                return new ItemSwipeTemplateCell{ View = MainGrid };
            });

but it throws nullreferenceexception

i think the problem is in the last line 

but what else should i return 

i tried a lot of returns but all throws the same exception 

please help me ASAP

 

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 08 Sep 2017, 06:32 AM
Hi,

I have updated the blog post where you have commented regarding the issue. Here is the approach:

listView.ItemSwipeContentTemplate = new DataTemplate(() =>
{
 
var mainGrid = new Grid { ColumnSpacing = 0, RowSpacing = 0, Padding = 0, Margin = 0 };
 
mainGrid.Children.Add(new Label { Text = "Sign", TextColor = Color.Red });
 
return mainGrid;
});

Please give it a try in your application.

Regards,
Stefan Nenchev
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
0
mo
Top achievements
Rank 1
answered on 10 Sep 2017, 12:40 PM

hello

sorry but this solution is not working 

it needs a template written in xaml file

which is so weird!!

so i add this template to my view container page xaml in the page resources 

and used it in the view from the resources 

0
Stefan Nenchev
Telerik team
answered on 13 Sep 2017, 02:17 PM
Hi ,

Testing in a sample application seems to work at my end. I have attached it for your reference.

Regards,
Stefan Nenchev
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
mo
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
mo
Top achievements
Rank 1
Share this question
or