Click here to Skip to main content
15,920,603 members
Home / Discussions / WPF
   

WPF

 
QuestionTreeViewItem and opening a modal dialog from the contextmenu (Properties) [modified] Pin
Diving Flo13-Apr-10 3:30
Diving Flo13-Apr-10 3:30 
Hi there!

In our application (we use MVVM pattern) we have a treeview that uses a ViewModel as DataContext. Each node then has its own ViewModel. Depending on the type there are different HierarchicalDataTemplates. In other words we have a ViewModel hierarchy. This works without any problems.

Now I implemented a context menu that should enable the user to open a modal dialog that shows some properties of the ViewModel (actually of the underlying business object). As it is not easy to open a modal dialog with MVVM pattern, I used the WPF Quick Recipes - Dialogs[^].

To abbreviate things, I need to place the following code snippet within my TreeViewItem. This is responsible to show the modal dialog when setting the ModalDialogViewModel property. I need to put this into the treeviewitem in order to get the correct DataContext from the ViewModel of the item.

<FrameworkElement DataContext="{Binding Path=ModalDialogViewModel}">
    <behaviour:DialogBehavior.DisplayModal>True</behaviour:DialogBehavior.DisplayModal>
</FrameworkElement>


Where and how can I place this in my TreeViewItem. ControlTemplate? DataTemplate?

Hopefully you understand what I mean. Otherwise tell me, what's not clear!

Thanks in advance!
Florian
modified on Tuesday, April 13, 2010 9:53 AM

GeneralRe: TreeViewItem and opening a modal dialog from the contextmenu (Properties) Pin
Diving Flo13-Apr-10 20:28
Diving Flo13-Apr-10 20:28 
AnswerRe: TreeViewItem and opening a modal dialog from the contextmenu (Properties) Pin
Diving Flo14-Apr-10 23:23
Diving Flo14-Apr-10 23:23 
QuestionOpen window in New browser window Pin
Tripathi Swati13-Apr-10 0:38
Tripathi Swati13-Apr-10 0:38 
AnswerRe: Open window in New browser window Pin
Abhinav S13-Apr-10 5:52
Abhinav S13-Apr-10 5:52 
GeneralRe: Open window in New browser window Pin
Tripathi Swati15-Apr-10 21:00
Tripathi Swati15-Apr-10 21:00 
QuestionPhilosophical question on MVVM lookups and practical one on entity fields.... Pin
RichardGrimmer12-Apr-10 23:57
RichardGrimmer12-Apr-10 23:57 
AnswerRe: Philosophical question on MVVM lookups and practical one on entity fields.... Pin
Abhinav S13-Apr-10 5:51
Abhinav S13-Apr-10 5:51 
GeneralRe: Philosophical question on MVVM lookups and practical one on entity fields.... Pin
RichardGrimmer13-Apr-10 9:05
RichardGrimmer13-Apr-10 9:05 
GeneralRe: Philosophical question on MVVM lookups and practical one on entity fields.... Pin
Abhinav S13-Apr-10 18:31
Abhinav S13-Apr-10 18:31 
GeneralRe: Philosophical question on MVVM lookups and practical one on entity fields.... Pin
RichardGrimmer13-Apr-10 21:30
RichardGrimmer13-Apr-10 21:30 
QuestionSelecting an item as per value in combobox in wpf Pin
dashingsidds12-Apr-10 22:50
dashingsidds12-Apr-10 22:50 
AnswerRe: Selecting an item as per value in combobox in wpf Pin
Arun Jacob12-Apr-10 22:58
Arun Jacob12-Apr-10 22:58 
GeneralRe: Selecting an item as per value in combobox in wpf [modified] Pin
dashingsidds12-Apr-10 23:26
dashingsidds12-Apr-10 23:26 
AnswerRe: Selecting an item as per value in combobox in wpf Pin
Arun Jacob12-Apr-10 23:30
Arun Jacob12-Apr-10 23:30 
GeneralRe: Selecting an item as per value in combobox in wpf Pin
dashingsidds12-Apr-10 23:41
dashingsidds12-Apr-10 23:41 
GeneralRe: Selecting an item as per value in combobox in wpf Pin
Arun Jacob12-Apr-10 23:47
Arun Jacob12-Apr-10 23:47 
AnswerRe: Selecting an item as per value in combobox in wpf Pin
Sunil Scaria12-Apr-10 23:15
Sunil Scaria12-Apr-10 23:15 
GeneralRe: Selecting an item as per value in combobox in wpf Pin
dashingsidds12-Apr-10 23:28
dashingsidds12-Apr-10 23:28 
GeneralRe: Selecting an item as per value in combobox in wpf Pin
Sunil Scaria12-Apr-10 23:34
Sunil Scaria12-Apr-10 23:34 
GeneralRe: Selecting an item as per value in combobox in wpf Pin
dashingsidds12-Apr-10 23:44
dashingsidds12-Apr-10 23:44 
QuestionAccessing a WPF object inside a class Pin
Prasoon Chaudhary12-Apr-10 20:44
Prasoon Chaudhary12-Apr-10 20:44 
AnswerRe: Accessing a WPF object inside a class Pin
Arun Jacob12-Apr-10 23:34
Arun Jacob12-Apr-10 23:34 
GeneralRe: Accessing a WPF object inside a class Pin
Prasoon Chaudhary12-Apr-10 23:40
Prasoon Chaudhary12-Apr-10 23:40 
AnswerRe: Accessing a WPF object inside a class Pin
Arun Jacob12-Apr-10 23:46
Arun Jacob12-Apr-10 23:46 

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.