Mobigital
Mobigital

Reputation: 759

Xamarin ViewCell: how to turn off > touch action?

When using ViewCell with TableView it shows a right arrow > (circled in red) and the whole cell can be touched - I suppose to select it and slide a new page from right to left to "drill into details".

Can someone advise on how to disable the display of > ? Looks that ViewCell.IsEnabled = false turns off the touch action.

enter image description here

Here is some code in my class deriving from ContentPage that creates the table section:

public class SamplePage : ContentPage
{

    public SamplePage()
    {
        var gridLengthStar = new GridLength(1, GridUnitType.Star);

        // GRIDSAMPLE CODE
        var gridSample = new Grid
        {
            RowDefinitions =
            {
                new RowDefinition {Height = GridLength.Auto},
                new RowDefinition {Height = GridLength.Auto}
            },
            Padding = new Thickness(20, 20, 20, 20),
            ColumnDefinitions =
            {
                new ColumnDefinition {Width = gridLengthStar},
                new ColumnDefinition {Width = gridLengthStar}
            },
        };

        gridSample.Children.Add ( new Label() { Text = "Data1" }, 0, 0);
        gridSample.Children.Add ( new Label() { Text = "Data2" }, 1, 0);

        gridSample.Children.Add ( new Label() { Text = "Data3" }, 0, 1);
        gridSample.Children.Add ( new Label() { Text = "Data4" }, 1, 1);

        var tableView = new TableView
        {
            HasUnevenRows = true,
            Intent = TableIntent.Form,
        };

        tableView.Root = new TableRoot
        {
            new TableSection("SECTION TITLE")
            {
                (new ViewCell {View = gridSample, IsEnabled =  false})
            }
        };

        Content = new StackLayout()
            {
                Children = { tableView } ,
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.Start,
                Spacing = 10
            };

    }
}

Upvotes: 0

Views: 916

Answers (1)

Michael Rumpler
Michael Rumpler

Reputation: 335

That arrow can be shown on iOS if you set

Accessory = UITableViewCellAccessory.DisclosureIndicator;

in your UITableViewCell.

Xamarin.Forms usually doesn't set this, so the arrow should not be shown. If it is there, then you have some renderer, Effect or other component which sets it in the iOS code.

Upvotes: 1

Related Questions