Click here to Skip to main content
15,909,822 members
Home / Discussions / WPF
   

WPF

 
QuestionBinding RelativeSource Pin
Jammer12-Jul-10 5:34
Jammer12-Jul-10 5:34 
AnswerRe: Binding RelativeSource Pin
Pete O'Hanlon12-Jul-10 6:39
mvePete O'Hanlon12-Jul-10 6:39 
GeneralRe: Binding RelativeSource Pin
Jammer12-Jul-10 22:17
Jammer12-Jul-10 22:17 
GeneralRe: Binding RelativeSource Pin
Pete O'Hanlon13-Jul-10 2:30
mvePete O'Hanlon13-Jul-10 2:30 
GeneralRe: Binding RelativeSource Pin
Jammer13-Jul-10 5:46
Jammer13-Jul-10 5:46 
QuestionHow to access view in view model Pin
Joe Rozario12-Jul-10 0:37
Joe Rozario12-Jul-10 0:37 
AnswerRe: How to access view in view model Pin
Pete O'Hanlon12-Jul-10 1:26
mvePete O'Hanlon12-Jul-10 1:26 
AnswerRe: How to access view in view model Pin
Member 341039816-Jul-10 15:30
Member 341039816-Jul-10 15:30 
I don't mean to be rude, but if you are trying to access your view in your VM, then your OOP skills need some refactoring.

To try and be not such an ahole...I think what you are saying is that you have a view that contain another view and they share a VM. The main view we can call V1 - the subordinate we call V2. I'm guessing your V2 is simply not visible. In this case, you want to bind the visibility to a property on your VM (like IsOrdersLoaded or something) and use bool2invis converter. When you command fires, it should simply set this property to true (and your properties setter should call OnPropertyChanged("IsOrdersLoaded")).

On the other hand - if you are trying to "inject" V2 into V1 (or anywhere else in your layout) and it needs to be dynamic (i.e. the command operation knows what V2 should be) - then you should consider basically the same approach, but your V1 (or whatever else) should contain a ContentPresenter that is capable of taking content as a view. This gets a bit trickier when using Commands since they don't return anything - and the one excpetion to the rule (imo) where View Models "know" about views. Essentially your content presenter's content is bound to a property on your view model via a property something like ...

internal FrameworkElement SubContent { get { return this.subContent; } set { this.subContent = value; OnPropertyChanged("SubContent"); } }

and this command of your's simply executes to instantiate your new view and sets that view to this.subContent. Visibility of the content presenter should be implemented as a "is content null" kind of value converter.

Honestly, I personaly hate this approach - I much prefer command repositories that are decoupled from my MV (so the command itself isn't even in the MV) - makes much more sense for testing when I can spin off views from unit tests and have nothing to do with my V1 or MV. If you went this direction, however, you need to add OnCommandExecuted<t> type events to your own command infrastructure to capture the T and propegate back up to the code-behind in the view, which simply sets this.V2Container.Content = T.View type of thing.

I hope that helps a little? If you can be a little more clear about your use case, I can certainly be more helpful.

-dec
Questionsilverlight4 tools for visual studio 2010 fails with the following error… HELP! Pin
Tiju John11-Jul-10 22:35
Tiju John11-Jul-10 22:35 
AnswerRe: silverlight4 tools for visual studio 2010 fails with the following error… HELP! Pin
Abhinav S11-Jul-10 23:37
Abhinav S11-Jul-10 23:37 
AnswerRe: silverlight4 tools for visual studio 2010 fails with the following error… HELP! Pin
Kunal Chowdhury «IN»12-Jul-10 8:17
professionalKunal Chowdhury «IN»12-Jul-10 8:17 
GeneralRe: silverlight4 tools for visual studio 2010 fails with the following error… HELP! Pin
Tiju John12-Jul-10 18:55
Tiju John12-Jul-10 18:55 
AnswerRe: silverlight4 tools for visual studio 2010 fails with the following error… HELP! Pin
Kunal Chowdhury «IN»12-Jul-10 19:36
professionalKunal Chowdhury «IN»12-Jul-10 19:36 
GeneralRe: silverlight4 tools for visual studio 2010 fails with the following error… HELP! Pin
Tiju John16-Jul-10 5:36
Tiju John16-Jul-10 5:36 
QuestionWant to learn Silverlight from scratch in ASP.Net Pin
Amit Spadez11-Jul-10 21:38
professionalAmit Spadez11-Jul-10 21:38 
AnswerRe: Want to learn Silverlight from scratch in ASP.Net Pin
Abhinav S11-Jul-10 22:06
Abhinav S11-Jul-10 22:06 
GeneralRe: Want to learn Silverlight from scratch in ASP.Net Pin
Amit Spadez11-Jul-10 22:13
professionalAmit Spadez11-Jul-10 22:13 
AnswerRe: Want to learn Silverlight from scratch in ASP.Net Pin
Abhinav S11-Jul-10 23:08
Abhinav S11-Jul-10 23:08 
AnswerRe: Want to learn Silverlight from scratch in ASP.Net Pin
Kunal Chowdhury «IN»12-Jul-10 17:23
professionalKunal Chowdhury «IN»12-Jul-10 17:23 
QuestionComboBox Items (Binding?) Pin
seblake11-Jul-10 13:31
seblake11-Jul-10 13:31 
AnswerRe: ComboBox Items (Binding?) Pin
Jammer11-Jul-10 22:43
Jammer11-Jul-10 22:43 
GeneralRe: ComboBox Items (Binding?) Pin
seblake13-Jul-10 16:58
seblake13-Jul-10 16:58 
GeneralRe: ComboBox Items (Binding?) Pin
Jammer14-Jul-10 1:36
Jammer14-Jul-10 1:36 
GeneralRe: ComboBox Items (Binding?) Pin
seblake14-Jul-10 8:03
seblake14-Jul-10 8:03 
GeneralRe: ComboBox Items (Binding?) Pin
Jammer14-Jul-10 23:37
Jammer14-Jul-10 23:37 

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.