Tuesday, 17 May 2016

Call User control event from parent window WPF c#

//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