Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

member names cannot be the same as their enclosing type in g.cs file

Tags:

c#

wpf

xaml

I've already searched for a solution to this problem in StackOverflow 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': member names cannot be the same as their enclosing type

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

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.

like image 831
grizzo Avatar asked Apr 27 '14 17:04

grizzo


1 Answers

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

Example :

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

Solution :

  • 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
like image 131
aybe Avatar answered Oct 12 '22 05:10

aybe