Click here to Skip to main content
16,017,297 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Newbie data template/DataContext question Pin
Jörgen Sigvardsson17-Mar-08 2:52
Jörgen Sigvardsson17-Mar-08 2:52 
GeneralIs it possible to create a text editor Pin
Dewey14-Mar-08 18:51
Dewey14-Mar-08 18:51 
GeneralRe: Is it possible to create a text editor Pin
Pete O'Hanlon16-Mar-08 10:09
mvePete O'Hanlon16-Mar-08 10:09 
GeneralRe: Is it possible to create a text editor Pin
Michael Sync5-May-08 16:45
Michael Sync5-May-08 16:45 
GeneralDumb Button Question alert! Pin
Jammer13-Mar-08 13:41
Jammer13-Mar-08 13:41 
GeneralRe: Dumb Button Question alert! Pin
User 27100913-Mar-08 15:21
User 27100913-Mar-08 15:21 
GeneralRe: Dumb Button Question alert! Pin
Jammer14-Mar-08 0:06
Jammer14-Mar-08 0:06 
GeneralRe: Dumb Button Question alert! Pin
User 27100914-Mar-08 1:42
User 27100914-Mar-08 1:42 
x:Name is fine.

If you are in the code behind of a user control, you will not see the objects in the main window.

This encapsulation and separation of responsibilities is a feature of .NET and object oriented languages.

By having the user control address the controls on the main form you are creating a dependency inversion which "normally" we try to stay away from.

If the design of your application requires this you do have several options.

1. You can get a reference to the main window, then cast it to the type your main window is, then you can reference the controls on the main window.

2. You can have the user control raise an event that the the main window services and then allow the main window to set its controls.

3. You can expose properites on the user control that the main window can bind to, that controls their visibility.

4. You can pass a reference to the controls that the user control will effect in and then the user control can control them.

I'm sure there are other ways to accomplish this.

Cheers, Karl

» CodeProject 2008 MVP

My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

Just a grain of sand on the worlds beaches.



modified 27-Feb-21 21:01pm.

GeneralRe: Dumb Button Question alert! Pin
Jammer14-Mar-08 7:14
Jammer14-Mar-08 7:14 
GeneralRe: Dumb Button Question alert! Pin
User 27100914-Mar-08 7:47
User 27100914-Mar-08 7:47 
GeneralRe: Dumb Button Question alert! Pin
Jammer14-Mar-08 8:01
Jammer14-Mar-08 8:01 
GeneralRe: Dumb Button Question alert! Pin
User 27100914-Mar-08 8:14
User 27100914-Mar-08 8:14 
GeneralRe: Dumb Button Question alert! Pin
Jammer14-Mar-08 8:30
Jammer14-Mar-08 8:30 
GeneralRe: Dumb Button Question alert! Pete Can you look at this for him? Pin
User 27100914-Mar-08 8:42
User 27100914-Mar-08 8:42 
GeneralRe: Dumb Button Question alert! Pete Can you look at this for him? Pin
Jammer14-Mar-08 9:28
Jammer14-Mar-08 9:28 
GeneralRe: Dumb Button Question alert! Pete Can you look at this for him? Pin
Pete O'Hanlon16-Mar-08 9:57
mvePete O'Hanlon16-Mar-08 9:57 
GeneralRe: Dumb Button Question alert! Pete Can you look at this for him? Pin
Jammer16-Mar-08 10:03
Jammer16-Mar-08 10:03 
GeneralRe: Dumb Button Question alert! Pete Can you look at this for him? Pin
Pete O'Hanlon16-Mar-08 10:05
mvePete O'Hanlon16-Mar-08 10:05 
GeneralRe: Dumb Button Question alert! Pete Can you look at this for him? Pin
Jammer16-Mar-08 10:08
Jammer16-Mar-08 10:08 
GeneralThe killer question Pin
Ed.Poore13-Mar-08 9:52
Ed.Poore13-Mar-08 9:52 
GeneralRe: The killer question Pin
User 27100913-Mar-08 11:35
User 27100913-Mar-08 11:35 
GeneralRe: The killer question Pin
Ed.Poore13-Mar-08 11:40
Ed.Poore13-Mar-08 11:40 
GeneralRe: The killer question Pin
User 27100913-Mar-08 15:24
User 27100913-Mar-08 15:24 
GeneralRe: The killer question Pin
Ed.Poore13-Mar-08 15:49
Ed.Poore13-Mar-08 15:49 
GeneralRe: The killer question Pin
Pete O'Hanlon14-Mar-08 2:21
mvePete O'Hanlon14-Mar-08 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.