0

I am new to WPF. I have requirement to create a window (as below. Ignore background color. Just gave color to distinguish different panels). On click on next, center panel (with frame) will load another page/user control. This is working fine.

Now I need to validate data/input of the form when user clicks Next. If everything is fine, next control should load. But I am unable to get controls from frame to Mainwindow.

enter image description here

Can someone please help me on how can I access controls of page/usercontrol from Main Window. I have a label after each control which will show error message if values are not not provided or are incorrect.

Sunil Agarwal
  • 4,097
  • 5
  • 44
  • 80
  • Er... You can add properties to your user control which return its controls. But that's not how WPF is designed to work (accessing individual controls from a user control doesn't sound like a good idea in *any* UI framework). You should learn MVVM. – Athari Jun 10 '13 at 10:45

1 Answers1

0

If you are using MVVM Pattern, On your next click, you can raise an event from the usercontrol View Model and get some response back to the Main Page's View Model where your Next code resides.

OR

You can access the Usercontrol's Datacontext in Main Page's View Model, Cast it to your Usercontrol's View Model. Take the information and just do your validation.

Hope this will help you...

itb564
  • 223
  • 4
  • 10