Wednesday 20 July 2016

Call Usercontrol Event from parent widnow C# WPF

//In userControl

public event EventHandler HelpButtonUpdated;

        public Header()
        {
            InitializeComponent();
        }

        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //Null check makes sure the main page is attached to the event
            if (this.HelpButtonUpdated != null)
                this.HelpButtonUpdated(new object(), new EventArgs());

        }



Main Window
  header.HelpButtonUpdated += new EventHandler(MyEventHandlerFunction_HelpButtonUpdated);
public void MyEventHandlerFunction_HelpButtonUpdated(object sender, EventArgs e)
        {
            PopupHelp.IsOpen = true;
            Opacity = 0.5;          
        }


No comments:

Post a Comment