Can someone tell me what I'm doing wrong while attempting to apply both subclassing and generics to a XAML UserControl? I can successfully subclass a XAML UserControl but when generics gets added in then things, and I apologize for descending to technical terms, go all wonky.
The following code, a much simplified version of what I'm trying to do (ModelViewController in Wpf), should know that the class supports a resources section but does not.
This is the non-xaml class that is being used as the base class.
namespace WpfMvc.MVC
{
public class View<T> : UserControl
{
}
}This is the code-behind after inserting changes needed to support the subclassing.
namespace WpfMvc.One
{
/// <summary>
/// Interaction logic for OneView.xaml
/// </summary>
public partial class OneView : View<OneController>
{
public OneView()
{
InitializeComponent();
}
}
}Note the use of the generic specifiying that a type of OneController is to be passed to the View. In this case OneController is an empty class that is itself derived from Controller.
This is XAML after what was originally a XAML UserControl with a resources section was subclassed.
<mvc:View
x:Class="WpfMvc.One.OneView"
x:TypeArguments="local:OneController"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mvc="clr-namespace:WpfMvc.MVC"
xmlns:local="clr-namespace:WpfMvc.One"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"><mvc:View.Resources></mvc:View.Resources><Grid></Grid></mvc:View>The above has an error in that Dev Studio 2012 is insisting that "The name "View" does not exist in the namespace "clr-namespace:WpfMvc.MVC"." The 'View' it is complaining about is the one associated with <mvc:View.Resources>. Previously, when this was still a subclassed View that did not use generics, no error was reported. Therefore, it looks like there is something wrong with the way that I'm specifying the resources section but I'll be darned if I know what it is.
Richard Lewis Haggard