-
Data binding maybe?
I have a program that has to WPF Windows.
In the first MainWindow I have a menu to open a an image file.
The menu opens an OpenDialog box to let the user choose an image, after the image is chosen an instance of the second WPF Window ImageWindow is created and the title is changed to the file path of the selected file
string filename = dlg.FileName;
Window imgWindow = new CToolsImageWindow();
// Change Image window to filename of image
imgWindow.Title = filename;
imgWindow.Show();
On the ImageWindow there is a Image Control named imgPicture, I want to change the imgPicture.Source to the file that was selected in the OpenDialog window, however I cannot access the imgPicture from the scope of MainWindow.
Does this require data binding or a simple access modifier or ? I changed the XAML to FieldModifier="public" for the imgPicture and nothing.
Am I making a gross conceptual error or what. I've spent hours trying to figure this out with no luck.
-
Re: Data binding maybe?
It's the same question as this guy asked http://stackoverflow.com/questions/2...-window-in-wpf
But none of the solutions given work, I am not using the classname to try to access the controls property, I am using the new instance i created.
I tried encapsulating it into a method in the Image window but i can't access the method from the MainWindow either.
This is probably very easy but I feel like I have tried everything.
-
Re: Data binding maybe?
Finally, I solved this problem i was doing Window imgWindow = new ImageWindow(); instead of var imgWindow = new ImageWindow();
Maybe that will help someone else in the future.