Reputation: 2588
I've recently built a Volley Scoreboard Application in Windows Forms that I'm trying to convert to WPF.
My first Window has all the controls to manage the game, while the second one is the window that will be projected on the big screen.
In Windows Forms I was able to update both labels (example, home_score on both Main and Projected) from a single point in code, but I don't seem to find a way to do this in WPF.
Any chance I'm missing something? Relatively new to WPF.
Upvotes: 0
Views: 91
Reputation: 6452
You need to:
after this:
otherWin.ScoreLabel.Text = "123";
Upvotes: 0
Reputation: 61339
If it makes sense to have both pages (Views) utilizing the same View Model; which it sounds like it might given your use case, then the answer is simple:
Bind both labels (really,
TextBlock
s) to the same property. When the property is updated; the binding engine will update both UIs.
If that isn't an option; the "master" View Model could invoke a method on the Model that would raise an event (ScoreUpdated
). The "display" View Model would register for this event and update an appropriate property so that its View will pick up the change.
Upvotes: 1