hradecek
hradecek

Reputation: 2513

Dialog Window Change the Main Window

how to make something like this:(Screen is not from my app) enter image description here
When is change the button in dialogBox, it automatically change the Bitmap in MainWindow... I hope you understand my prob ;d So how can i make this dialog window ? Or how can i get access to Mainwindow variables from dialogWindow?

Upvotes: 0

Views: 262

Answers (2)

GameAlchemist
GameAlchemist

Reputation: 19294

Define a class where you put all information relevant to your item. All properties uses NotifyPropertyChanged.
One of this property is the Title. So now in your main window you have a TextBlock bound your object title (it might be within a control that draws the object and write the title above), and when you click on a button it opens another window. In the constructor( new()) of the second window, you give the drawn object as argument.
So when you change the title in the second window, it gets updated in the first.

Upvotes: 0

Philippe Lavoie
Philippe Lavoie

Reputation: 2593

If you have no architecture to support that (like MVVM), you can simply use the Application object in you dialog code-behind:

MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
mainWindow.button1.Content = "Dialog rename me";

Application object is set on your application execution and is global.

Upvotes: 1

Related Questions