I have a C# code which I would like to run through a simple button click using WPF. I am not sure how to achieve this since the creation of a WPF solution in Visual Studio already comes with a .cs file.
If I delete the existing namespace, the program wouldn’t run, thus, is there any way I can add a second namespace and run it?
Thank you!
I have not tried anything in specific because of my lack of knowledge.
2
Answers
New WPF projects generate automatically some files that are:
1.App.xaml
2.MainWindow.xaml
‘App.xaml’ is the first file to be processed when your project is run
On line 5, open the file ‘MainWindow.xaml’. The program would not run if you deleted ‘MainWindow.xaml’ or ‘App.xaml’.
Maybe you think things are too complicated. Regarding wpf, you only need to follow the steps below to use the Button trigger method:
Put the mouse on the button, double-click the button when the mouse shows an arrow, and write the previous method to Button_Click(object sender, RoutedEventArgs e)
Start wpf, click the button to call the previous method