Hi,@Will Pittenger.
Reason: You could enter InitializeComponent by pressing Ctrl+left key to view the following code
System.Uri resourceLocater = new System.Uri("/t;component/base.xaml", System.UriKind.Relative);
That is, the program will use the Uri to find the xaml file it should be associated with. If it cannot find the file, it will report the error you see.(The file does not appear to be editable manually).
Solution
Way 1(Recommend):
Create a class without xaml to define the window.For example, the following code is just a simple class.
public class newBase:Window
{
public newBase()
{
StackPanel stackPanel = new StackPanel();
stackPanel.Background = Brushes.DarkGray;
Button button = new Button();
button.Content = "HAHA";
button.Width = 200;
button.Height = 50;
button.HorizontalAlignment = HorizontalAlignment.Center;
stackPanel.Children.Add(button);
this.AddChild(stackPanel);
}
}
Then, reference it in the t project and derive it to inherit newBase.(At this time, derive does not need to call InitializeComponent() in the constructor;)
Way 2:
Copy base.xaml (delete base.xaml.cs) to the same folder as derived.cs
Adjust the code
class derived : g._base
{
public derived()
{
InitializeComponent();
}
}
In base.xaml (project t) you could continue to define your page
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.