Binding to a property of the DataContext of another control?

I would recommend having your game and gameBoard properties on a wrapper view model and then setting the datacontext of your view to the wrapper view model. That way in your button's Fill binding you could simply reference the appropriate property on your view model.

Up vote 1 down vote favorite share g+ share fb share tw.

Iv'e got 2 panels in an app game they are both bound to different elements . GameDetailsPanel. DataContext = game ; GameBoardPanel.

DataContext = gameBoard ; *Game has a Turn Property * . Public Class Game { public bool Turn{ get; set;} } now I need to bind one of GameBoardPanel to the value of the Property Turn , *for example : something along the lines of * how can I reference GameDetailsPanel. DataContext in my binding?

Wpf data-binding link|improve this question edited Mar 11 at 11:22H.B.43k61645 asked Mar 11 at 3:42eran otzer565211 74% accept rate.

I would recommend having your game and gameBoard properties on a wrapper view model and then setting the datacontext of your view to the wrapper view model. That way in your button's Fill binding you could simply reference the appropriate property on your view model: public Class Wrapper_ViewModel { public Game game{ get; set; } public T gameBoard{ get; set; } } However, for more one-off scenarios you could use the relative source binding attribute and hook another elements data context, as in this example: wpf: Access parent DataContext from DataTemplate.

Yeah I thought of that I just thought maybe I could work around this because I only need it for this specific place. – eran otzer Mar 11 at 3:59 Check out my edit above for another option if you're looking for a simple one-off binding. – KodeKreachor Mar 11 at 4:14.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions