-1

Hi guys I have a problem

i need the info I enter in a text box on my main window to update a label on my second window called script.

The text box name is client and the label name is client-label

I have tried many different ways to do this and still not coming right

how can I do this?

PS. I am new to the programming world so please give me step by step instructions anywhere possible :)

  • You can do that using `delegate`s. See my answer to the [Transfer data Between two Usercontrol inside of Mainwindows](http://stackoverflow.com/questions/24440055/transfer-data-between-two-usercontrol-inside-of-mainwindows/24440307?noredirect=1#comment37890468_24440307) question and the linked questions for code examples. – Sheridan Jun 29 '14 at 21:23

2 Answers2

1

Pertinent to your requirement (i.e. two WPF windows with sync controls), it will require quite a bit of coding. Better (simpler) way is to create a pseudo-window, i.e. just a nested layout Grid within you main window containing all controls pertinent to that second window (you can set its visibility to collapse/visible in order to "simulate" pop-up window), and update a second TextBlockon .TextChanged event of the first TextBox (using code behind). Alternatively, you can apply data binding technique is XAML of the same single window.

Note: you can implement a splitter control to resize two 'sub-windows'.

In case you do prefer to implement second window, then refer to this example: Data Binding between two TexBoxes in different windows

Rgds,

Community
  • 1
  • 1
Alexander Bell
  • 7,842
  • 3
  • 26
  • 42
  • ...two windows... yeah, with just one window, data-binding would be the way to go, but with two windows code-behind is probably easier... –  Jun 29 '14 at 19:55
  • Thanks guys I will give them both a go, thanks so much for the help :) – Wesley Guastella Jun 29 '14 at 20:03
0

The "correct" way for this would probably be to have a view model for each view part in your gui and have them communicate through events. The Prism framework for WPF will help you with most of the plumbing for this. Se more about Prism here: http://compositewpf.codeplex.com

Morten
  • 339
  • 1
  • 7