CS50542和CS0103使用代码转换器将包含wpf控件的vb项目转换为c#

问题描述 投票:0回答:1

我有一个包含wpf控件的vb项目我正在使用Code Converter进行转换运行转换器并构建后,出现以下buid错误

Error   CS0542  'SpellControl': member names cannot be the same as their enclosing type  

Error   CS0103  The name 'InitializeComponent' does not exist in the current context

xaml是

<UserControl x:Class="SpellControl"
             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" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="400">
    <Grid>
        <TextBox x:Name="textSpell" SpellCheck.IsEnabled="True" Language="en-AU" FontSize="14" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Loaded="textSpell_Loaded">
        </TextBox>
    </Grid>
</UserControl>
c# wpf-controls
1个回答
0
投票

我必须编辑UserControl代码以添加名称空间

<UserControl x:Class="MyProjectNamespace.SpellControl"

其中MyProjectNamespace是项目应用程序选项卡中的默认命名空间。

已解决CS0103错误

要解决CS50542错误,我只需要删除生成的控件初始化程序

public partial class SpellControl
{
    public SpellControl()
    {
        InitializeComponent();
    }

    //public void SpellControl()
    //{
    //}
© www.soinside.com 2019 - 2024. All rights reserved.