Q:

The type 'MyApp' already contains a definition for 'MystatusBar'

MyApp.XAML
<StatusBar Name="MystatusBar" DockPanel.Dock="Bottom" BorderBrush="Black"
                 Background="{StaticResource DarkBrush}">
                <StatusBarItem>
                    <TextBlock x:Name="m_StatusBarLineInfo"/>
                </StatusBarItem>
                <StatusBarItem>
                    <Separator/>
                </StatusBarItem>
                <StatusBarItem>
                    <TextBlock x:Name="m_StatusBarMessage"/>
                </StatusBarItem>
            </StatusBar>

MyApp.g.cs
     #line 722 "..\..\MyApp.xaml"
        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
        internal System.Windows.Controls.Primitives.StatusBar MystatusBar;

 case 106:
            this.MystatusBar = ((System.Windows.Controls.Primitives.StatusBar)(target));
            return;

MyApp.xaml.cs
internal StatusBar MystatusBar;
case 110:
                    this.MystatusBar = (StatusBar)target;
                    break;

This is a usercontrol StatusBar . The error says "The type 'MyApp' already contains a definition for 'MystatusBar'"
The MyApp.g.cs file created automatically while building the project . I am stuck on this . 

A:

Whenever you name a XAML element like you do with:
<StatusBar Name="MystatusBar" ... />

Visual studio will create a member for you with that name so that you can access it from code-behind. This is the instance you see in MyApp.g.cs which is a generated file. It gets created automatically when you change the XAML.
Therefore, when you attempt to declare another reference with the same name yourself in your code behind (MyApp.xaml.cs), you rightly get an error, since all three of these files compile into into the same class.
You do not need your manual declaration. You can just use the one that Visual Studio has already created for you.

