Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Creating a custom ViewCell in XAML

$
0
0

I'm trying to create a custom ViewCell in XAML - prior to this I've done everything in code

<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="m.transport.VehicleCell">
    <ViewCell.Content>
        <StackLayout>
        <Label Text="This is my label"></Label>
        </StackLayout>
    </ViewCell.Content>
</ViewCell>

However, this results in a build error -

The type m.transport.VehicleCell cannot be used as type parameter TView in the generic type or method Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this TView, System.Type). There is no implicit reference conversion from m.transport.VehicleCell to Xamarin.Forms.VisualElement (CS0311)

The other examples I've found so far of custom cells are either done in code, or the cell is part of a larger XAML block that includes the table, so the cell itself is not easily reusable.

Can I create just a reusable custom cell in XAML?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>