Item swipe template (URGENT)

4 posts, 0 answers
  1. mo
    mo avatar
    10 posts
    Member since:
    Aug 2017

    Posted 07 Sep Link to this post

    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

     

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    501 posts

    Posted 08 Sep Link to this post

    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
  3. mo
    mo avatar
    10 posts
    Member since:
    Aug 2017

    Posted 10 Sep Link to this post

    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 

  4. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    501 posts

    Posted 13 Sep Link to this post

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