locked
Problem with Inheritance RRS feed

  • Question

  • Hello,

     

    I have been having an issue with my application.

    I have a Class that derives from UserControl as an abstract, lets call it Control A . then I am trying to make another control inherit from Control A so that I can use the functionality of Control A plus whatever i add to the new control (Control B )

     

    Here is the code for Control A:

    //usings
    
    namespace MyNamespace
    {
       public abstract class ControlA: UserControl
       {
    
       //Stuff Goes here
    
       }
    }
    

    That compiles fine. The code for control B is:

    //usings
    
    namespace MyNamespace
    {
       /// <summary>
       /// Interaction logic for ControlB.xaml
       /// </summary>
    
       public partial class ControlB: ControlA 
       { 
           public ControlB() 
          { 
            InitializeComponent();
          }
    
          //Stuff Goes Here
       }
    }
    
    

     

    The xaml for control B looks like:

    <src:ControlA
       x:Class="MyNamespace.ControlB"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:src="clr-namespace:MyNamespace" 
       Height="50" Width="100">
      
      <Grid>
     
      </Grid>
    
    </src:ControlA>
    
     

    I thought that should work fine. but I am getting the following errors:

     

    Error    1    Partial declarations of 'MyNamespace.ControlB' must not specify different base classes    MyApplication\MyNamespace\ControlB.xaml.cs    20    26    MyApplication


    Error    2    Assembly 'MyNamespace' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built.    MyApplication\MyNamespace\ControlB.xaml    5    15    MyApplication


    Error    3    The type 'src:ControlA' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.    MyApplication\MyNamespace\ControlB.xaml   1    2    MyApplication

     

    What am i doing wrong?

     

    Friday, July 9, 2010 4:51 PM

Answers

  • Found the problem. MyNamespace had a "_" in it. Apparently xaml doesnt like the "_". Hope this helps someone else.

     

    • Marked as answer by Barb3958 Friday, July 9, 2010 5:16 PM
    Friday, July 9, 2010 5:16 PM