0

I have been working AT this for two days now, the simplest one I could explain what I'm trying to do is on this website if you search for "C# - handling WPF usercontrol events in winforms".

It uses a Radio Button, but the code doesn't work, I have been searching Google and nothing gives me the correct answer, always something wrong.

I want the textbox to have text in stating User has clicked the radio button, the event does not get the data from usercontrol, the code in WPF seems fine, the Form1 needs to pick up that the event happened.

public Form1()
    {

        InitializeComponent();
        UserControl1.onRadioButtonClick += UserControl1.ucRadioButtonHandler(userControl11_onRadioButtonClick);

    }


    void userControl11_onRadioButtonClick(object sender, ucButtonEventArgs e)
    {
        System.Windows.Controls.RadioButton rb = (System.Windows.Controls.RadioButton)sender;
        textBox1.Text = "User Selected Radiobutton";

    }

Type or namespace name 'ucButtonEventArgs' could not be found and Object refrence is required for the non static field.

If anyone can point me in the right direction. Thank you

CODE_DOWNLOAD

Code

  • Did you attach the RadioButtonClick on your Radio Button? Refer on this link: https://www.dotnetperls.com/radiobutton-wpf – TerribleDog Sep 12 '19 at 02:41
  • I think you're asking if I did this: private void RadioButton_Checked(object sender, RoutedEventArgs e) { if (onRadioButtonClick != null) { onRadioButtonClick(sender, new ucButtonEventArgs()); } } the XAML – Oxley Pilot Sep 12 '19 at 04:57
  • I was using Usercontrol11, in my selection I noticed an option for UserControl12, when I used it it works. Thanks anyway! – Oxley Pilot Sep 12 '19 at 05:22

0 Answers0