© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
20 replies
Falco

MainWindow' does not contain a definition for 'Button_Click'

Why is this occuring? Even if I delete the method in my code, and the xalm code for the button, the error is still there. Even if I rebuild/save/restart my project.

Things I've already tried which should solve it according to the internet:
- Make sure namespace matches Xaml and in code(Both have EpicUnfriender)
- I deleted bin/obj and restarted project
- Deleted both xalm code for the button, and method Button_Click but error still occurs

Code:
using System.Windows;
using System.Windows.Input;
using NHotkey.Wpf;
using NHotkey;

namespace EpicUnfriender
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();;
        }
        // StartButton
        public void Button_Click(object sender, RoutedEventArgs e){}
    }
} 
using System.Windows;
using System.Windows.Input;
using NHotkey.Wpf;
using NHotkey;

namespace EpicUnfriender
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();;
        }
        // StartButton
        public void Button_Click(object sender, RoutedEventArgs e){}
    }
} 
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

I need Help with this error:'MainWindow' does not contain a definition for 'LibraryTab_Click' and no
C#CC# / help
10mo ago
❔ FreeImage does not contain a definition for GetBitmap
C#CC# / help
3y ago
❔ ✅ 'ConsoleColor' does not contain a definition for 'DrawingColor'
C#CC# / help
3y ago
❔ 'Observable' does not contain a definition for 'Create'
C#CC# / help
4y ago