部件名称不能一样g.cs文件其封闭类型

部件名称不能一样g.cs文件其封闭类型

问题描述:

我已经搜索了在计算器解决这个问题,但显然这一次是不同的。
在我的Windows Phone应用程序,当用户按下特定的按钮,该应用程序应该他重定向到一个特定的全景页,所以我跟着这个如何:

I've already searched for a solution to this problem in * but apparently this time is different. In my Windows Phone application when the user presses a specific button the app should redirect him to a specific Panorama Page so I followed this how to:

http://blogs.msdn.com/b/aschapiro/archive/2012/07/21/navigating-directly-to-a-specific-screen-inside-a-panorama-or-pivot -page.aspx

但是,当我编译解决方案出现这个错误:

But when I compile the solution this error appears:

donazione:成员名称不能与它们的封闭类型

'donazione': member names cannot be the same as their enclosing type

但这个错误是在.G cs文件澳编译期间创建的donazione.xaml文件,所以我看着它和错误是:

But this error is in the .g.cs file o the donazione.xaml file created during the compilation, so I looked at it and the error is:

namespace Avis {


public partial class donazione : Microsoft.Phone.Controls.PhoneApplicationPage {

    internal System.Windows.Controls.Grid LayoutRoot;

    internal Microsoft.Phone.Controls.Panorama donazione; <-- the error is in this line

    private bool _contentLoaded;

    /// <summary>
    /// InitializeComponent
    ....



Obviuously试图修改此文件将解决不了任何问题所以在这里它是donazione.xaml文件,这将导致这个错误:

Obviuously trying to modify this file wouldn't solve anything so here it is the donazione.xaml file which causes this error:

<phone:PhoneApplicationPage
x:Class="Avis.donazione"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait"  Orientation="Portrait"
shell:SystemTray.IsVisible="False">

<Grid x:Name="LayoutRoot">
    <controls:Panorama x:Name="donazione">

        <!--Panorama item one-->
        <controls:PanoramaItem Header="Il sangue">
            <Grid/>
        </controls:PanoramaItem>

        <!--Panorama item two-->
        <controls:PanoramaItem Header="Perché Donare">
            <Grid/>
        </controls:PanoramaItem>
        <controls:PanoramaItem Header="Chi può donare">
            <Grid/>
        </controls:PanoramaItem>
        <controls:PanoramaItem Header="Come donare">
            <Grid/>
        </controls:PanoramaItem>
        <controls:PanoramaItem Header="Tipi di donazione">
            <Grid/>
        </controls:PanoramaItem>
        <controls:PanoramaItem Header="FAQ">
            <Grid/>
        </controls:PanoramaItem>
    </controls:Panorama>
</Grid>



我该怎么面对它-to的那些,但是,除了附加元件中,初始的声明是相等的。

I confronted it with the how-to's ones but, except for the additional elements, the initial declarations are equal.

任何人都可以帮我吗?
感谢。

Anybody can help me? Thanks.

您不能在你的类成员被命名为喜欢你的类。

You can't have a member in your class which is named like your class is.

例如:

class Test
{
    int Test; // error
    int Test1; // OK
}



解决方案


  • 修改 donazione 变量到别的东西。

  • 的名称
  • 现在,因为它是一个.g.cs文件,你应该做的是从设计视图属性窗口

  • change the name of donazione variable to something else.
  • now since it is a .g.cs file you should do that from the design-view properties window