How to create a generic xaml user control in UWP?

Viewed 1008

I'm getting a weird XAML error that I don't understand that I'm hoping someone can help with. I am attempting to make a generic AxisBase user control that is capable of plotting any type of data. I then want to extend this to create a specific kind of axis, one that can graph dates on the X axis and doubles on the Y axis.

DateDoubleAxis.xaml

<axis:AxisBase  x:Class="project.Views.Controls.Chart.Axis.DateDoubleAxis"
                x:TypeArguments="system:DateTime, system:Double"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:axis="using:project.Views.Controls.Chart.Axis"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                xmlns:system="using:System">...</axis:AxisBase>


AxisBase.cs

namespace project.Views.Controls.Chart.Axis
{
    public class AxisBase<TX, TY> : UserControl {...}
}


DateDoubleAxis.xaml.cs

namespace project.Views.Controls.Chart.Axis 
{
    public sealed partial class DateDoubleAxis : AxisBase<DateTime, Double> {...}
}

But I'm getting a couple weird errors. In the xaml declaration of DateDoubleAxis I get the error

The name "AxisBase`2" does not exist in the namespace "using:project.Views.Controls.Chart.Axis"

The '`2' I believe comes from the fact that AxisBase has two generic types associated with it.



And then in the declaration of DateDoubleAxis I get the error:

Base class of 'project.Views.Controls.Chart.Axis.DateDoubleAxis' differs from declared in other parts

Along with the ironic resharper warning

Base type 'AxisBase' is already specified in other parts

I realize I'm doing something a little weird in trying to extend from my own user control, but I think that it makes sense in this context, and at the very least, a few users have suggested it here.

Can anyone point me to what I might be doing wrong?

1 Answers
Related