0

I have multiple xaml pages that have common functionality and I need to create a single .cs file to use them. So I commented all the code in my .cs for the .xaml and created a new .cs file to handle my "Test" page's functionality.

I followed the answer here but I'm getting the error:

  "The name 'InitializeComponent' does not exist in the current context "

as well as:

The type 'local:MainCode' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

Here's what I did:

In my .xaml page:

<**local:MainCode** x:Class="SilverlightApp1.Common.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
**xmlns:local="clr-namespace:SilverlightApp1.Common**"

And in my code page:

namespace SilverlightApp1.Common {

public class MainCode: UserControl
{
    public MainCode()
    {
    }

    public partial class Test: MainCode
    {
        public Test()
        {
            InitializeComponent();
        }
    }
} }

Can you help point me to the problem ?

Community
  • 1
  • 1
user3340627
  • 3,023
  • 6
  • 35
  • 80
  • Quacks like an indenting mistake. It is a nested class right now, its name is `SilverlightApp1.Common.MainCode.Test`. So yes, that's going to make it complain about `SilverlightApp1.Common.Test` – Hans Passant Mar 16 '14 at 14:33
  • Thank you for your reply, I tried this but it produced an error "The namespace 'SilverlightApp1.Common' already contains a definition for 'MainCode' for the Test.g.cs file . What is causing this ? – user3340627 Mar 16 '14 at 14:45
  • Delete the fiels from your debug folder and try to rebuild again – Sajeetharan Mar 16 '14 at 16:11

0 Answers0