ItemSwipeContentTemplate add button

2 posts, 0 answers
  1. Shalin
    Shalin avatar
    61 posts
    Member since:
    May 2015

    Posted 18 Oct 2017 Link to this post


    In radListview i enable swipe feature and implement ItemSwipeContentTemplate and add button to it.

    When i swipe item app crashes, if i use Label it is not crashing. I am binding data template even in page xaml it crashes. my button is without image just text.

    Is there any work arround to have Xamarin.Button with image and text on it ?

    p.s. If i have button with image only it works, but output window error is there, but app is not crashing

    Output window:

     [0:] FileImageSourceHandler: Could not find image or image file was invalid: File: 
    An unhandled exception occured.


    01.<DataTemplate x:Key="CommonItemSwipeTemplate">
    02.               <Grid Margin="0"
    03.                 Padding="0"
    04.                 ColumnSpacing="0"
    05.                 RowSpacing="0">
    06.                   <Grid.ColumnDefinitions>
    07.                       <ColumnDefinition Width="*" />
    08.                       <ColumnDefinition Width="70" />
    09.                   </Grid.ColumnDefinitions>
    11.                   <Button Grid.Column="1"
    12.                                BackgroundColor="Red"
    13.                                HorizontalTextAlignment="Center"
    14.                                Text="delete"                                
    15.                                TextColor="White"
    16.                                VerticalTextAlignment="Center"
    17.                                WidthRequest="70" />
    21.               </Grid>
    22.           </DataTemplate>
  2. Lance | Manager Technical Support
    Lance | Manager Technical Support avatar
    1193 posts

    Posted 18 Oct 2017 Link to this post

    Hi Shalin,

    That code you shared is not valid XAML. It looks like you just swapped out "Label" with "Button", but forgot to remove the properties that a Button does not have (e.g. the text alignments). You can test your Button XAML by first using it on the Page level, then once it works there use it for the ItemSwipeContentTemplate.

    Tip: I strongly recommend turning on XamlC, this will catch XAML issues during compilation instead of crashing at run-time. See the Xamarin documentation here for how to enable XamlC.

    Lance | Tech Support Engineer, Sr.
    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