更改.xaml页面的代码隐藏文件时,“InitializeComponent”不存在-error

时间:2014-03-16 14:07:25

标签: c# silverlight xaml code-behind initializecomponent

我有多个具有共同功能的xaml页面,我需要创建一个.cs文件才能使用它们。所以我在我的.cs中为.xaml评论了所有代码,并创建了一个新的.cs文件来处理我的"测试"页面的功能。

我按照了here的答案,但我收到了错误:

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

以及:

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

这就是我的所作所为:

在我的.xaml页面中:

<**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**"

在我的代码页中:

  

命名空间SilverlightApp1.Common {

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

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

你能指点我这个问题吗?

0 个答案:

没有答案