locked
MainWindow.xaml. cs- event code RRS feed

  • Question

  • Hello!

    Please if somone can help, I am still completely new at vs!

    Here is the code in the main window  MainWindow.xaml.cs, for a simple click event. It does not wrok, please, does anyone see why?

    It is vs 2010 at the moment.

    Many thanks!

    Code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;

    namespace mkevents1
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }



            private void Button_Click(object sender, RoutedEventArgs e)
            {
                MessageBox.Show("Star War");
            }


        }
    }

    Tuesday, April 19, 2016 9:02 AM

All replies

  • Open the Main Windows.xaml file, find the dial button you want to handle the Click event, make sure that the property (Event) "Click" is pointing to your event.
    Tuesday, April 19, 2016 10:00 PM
  • I also cant find "Click" among events, but I ment to find out why later. What is wrong in my .cs code? Am I missing sth and what? many thanks!!!
    Wednesday, April 20, 2016 12:53 PM
  • You can attach the file MainWindow.xaml this thread?
    Wednesday, April 20, 2016 1:06 PM
  • .xaml:

    <Window x:Class="WpfApplication4.MainWindow"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Button Click="Button_Click"/>
        </Grid>
    </Window>

    Wednesday, April 20, 2016 1:52 PM
  • I think I shoudl write "about" click event handler in .cs , probably after 

    InitializeComponent();

    but as I can't find Click event I am not sure I am doing well..many thanks!!!

    Wednesday, April 20, 2016 1:53 PM