0

我有多个具有通用功能的 xaml 页面,我需要创建一个 .cs 文件来使用它们。因此,我为 .xaml 注释了 .cs 中的所有代码,并创建了一个新的 .cs 文件来处理我的“测试”页面的功能。

我在这里遵循了答案,但出现了错误:

  "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();
        }
    }
} }

你能帮我指出问题吗?

4

0 回答 0