Reputation: 13
In my Xamarin.Forms project I am attempting to create a reusable ViewCell. I can't figure out, though, why when I simply create a ViewCell XAML and CS file using the VS-supplied template, it will not compile due to the following error:
"Partial declarations of 'DateViewCell' must not specify different base classes"
This error pops the second I create the file (as you'll see in the code below, I haven't added any code yet and this is all boilerplate) and I have a fully functional Xamarin.Forms project that compiles with no issues if I remove the extension.
DateViewCell.xaml:
<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="HelloWorld.Extensions.DateViewCell">
<ViewCell.View>
<StackLayout>
<Label Text="Hello Xamarin.Forms!" />
</StackLayout>
</ViewCell.View>
</ViewCell>
DateViewCell.xaml.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace HelloWorld.Extensions
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class DateViewCell : ViewCell
{
public DateViewCell()
{
InitializeComponent();
}
}
}
DateViewCell.xaml.g.cs:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("HelloWorld.Extensions.DateViewCell.xaml", "Extensions/DateViewCell.xaml", typeof(global::HelloWorld.Extensions.DateViewCell))]
namespace HelloWorld.Extensions {
[global::Xamarin.Forms.Xaml.XamlFilePathAttribute("Extensions\\DateViewCell.xaml")]
public partial class DateViewCell : global::Xamarin.Forms.ViewCell {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private void InitializeComponent() {
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(DateViewCell));
}
}
}
Sort of at a dead end here. I tried creating this "DateViewCell" extension manually and I get the same error that I did when I let VS create the file for me. I'm starting to wonder if this is a bug in Xamarin.
Anyone have any suggestions? The SO articles I could find that referenced this particular error didn't really apply and I'm out of ideas on better ways to search this... Thanks everybody.
Upvotes: 0
Views: 79