Click here to Skip to main content
15,888,968 members
Home / Discussions / WPF
   

WPF

 
Questionhow to navigate from 1 page to another Pin
hotthoughtguy6-Jan-10 8:18
hotthoughtguy6-Jan-10 8:18 
AnswerRe: how to navigate from 1 page to another Pin
Mark Salsbery6-Jan-10 8:47
Mark Salsbery6-Jan-10 8:47 
AnswerRe: how to navigate from 1 page to another Pin
April Fans6-Jan-10 19:10
April Fans6-Jan-10 19:10 
Questionsubclassing a treeviewitem Pin
hb521342146-Jan-10 4:21
hb521342146-Jan-10 4:21 
AnswerRe: subclassing a treeviewitem Pin
AspDotNetDev6-Jan-10 20:53
protectorAspDotNetDev6-Jan-10 20:53 
GeneralRe: subclassing a treeviewitem Pin
hb521342147-Jan-10 6:26
hb521342147-Jan-10 6:26 
QuestionRe: subclassing a treeviewitem Pin
AspDotNetDev7-Jan-10 13:44
protectorAspDotNetDev7-Jan-10 13:44 
AnswerRe: subclassing a treeviewitem Pin
hb521342147-Jan-10 15:07
hb521342147-Jan-10 15:07 
With regard to routed commands:

Lets say my application has two (bubbling) routed commands: SaveFile and SaveProject. The application also has a tree structure that represents a nested heirarchy of files and projects (and maybe other stuff as well). Lets say I have the following trivial heirarchical data templates (HDT):

<HDT x:Key="pItem" DT="{x:Type c:Project}" IS="{Binding Children}">
  <TextBlock Text="{Binding Name}" />
</HDT>
<HTD x:Key="fItem" DT="{x:Type c:File}" IS="{Binding Children}">
  <TextBlock Text="{Binding Name}" />
</HDT>
<HTD x:Key="other" DT="{x:Type c:Project}" IS="{Binding Children}">
  <TextBlock Text="{Binding Name}" />
</HDT>

How does one attach a routed command handler in the template to get a node to respond to a SaveFile command. In anything else, I'd throw in the basic:

<CommandBindings>
   <CommandBinding Command="{x:Static c:Cmds.SaveFile}" CanExecute="CanSave" Execute="Save"/>
</CommandBindings>

Unfortunately, I haven't been able to achieve this simple solution with a Heirarchical data template. Any suggestions?


On a side note, the ItemsControl (and thus TreeView & TreeViewItem) has a virtual function GetContainerForItemOverride, which allows one to return the container for their control, but unfortunately this call doesn't pass the object (or even the type) of object for which the container is being constructed. If it had, then it would be so trivial to implement a treeview that generates custom tree nodes without loosing any of the nice templating, styling or anything else. Too bad.




With regard to multiple UI elements refering to the same model item:

The link referenced in my original post showed how simple it is to use the model and have information update between the UI and the model. In the example, the author was searching for text in a tree. Because he linked the 'IsSelected' property of the TreeViewItem to a property (say 'ItemIsSelected' for clarity) in the model, he could walk the tree, and successively select each matching node in the search by merely setting the 'ItemIsSelected' property. Nice. I agree.

Now, throw that model into two separate trees and oops, setting the 'ItemIsSelected' causes both trees to change their selected item. Inorder to prevent that, but have that sort of functionality in both trees, one has to implement two properties in the model: 'ItemIsSelected_TV1', and 'ItemIsSelected_TV2' and in the different TreeView's.

The alternative is to use GetContainerFromElement. This technique more cleanly separates the UI and model, though I have to agree with the example's elegance (minus the resulting attachment to the UI).
GeneralRe: subclassing a treeviewitem Pin
hb521342147-Jan-10 15:14
hb521342147-Jan-10 15:14 
GeneralRe: subclassing a treeviewitem Pin
AspDotNetDev7-Jan-10 15:36
protectorAspDotNetDev7-Jan-10 15:36 
GeneralRe: subclassing a treeviewitem Pin
hb521342148-Jan-10 7:15
hb521342148-Jan-10 7:15 
GeneralRe: subclassing a treeviewitem Pin
hb521342148-Jan-10 7:46
hb521342148-Jan-10 7:46 
QuestionZoomIn and zoomout Pin
Member 47046755-Jan-10 18:36
Member 47046755-Jan-10 18:36 
AnswerRe: ZoomIn and zoomout Pin
Mark Salsbery6-Jan-10 8:49
Mark Salsbery6-Jan-10 8:49 
AnswerRe: ZoomIn and zoomout Pin
April Fans6-Jan-10 19:14
April Fans6-Jan-10 19:14 
QuestionHide controlbox or customize controlbox of WPF window [modified] Pin
Member 26504535-Jan-10 18:34
Member 26504535-Jan-10 18:34 
QuestionDatabinding and Value Converter questions Pin
Michael Eber4-Jan-10 10:39
Michael Eber4-Jan-10 10:39 
AnswerRe: Databinding and Value Converter questions Pin
Abhinav S4-Jan-10 16:05
Abhinav S4-Jan-10 16:05 
GeneralRe: Databinding and Value Converter questions Pin
Michael Eber5-Jan-10 6:27
Michael Eber5-Jan-10 6:27 
GeneralRe: Databinding and Value Converter questions Pin
Abhinav S5-Jan-10 17:00
Abhinav S5-Jan-10 17:00 
QuestionGridSplitter Behaviour Pin
rj_hogan4-Jan-10 5:35
rj_hogan4-Jan-10 5:35 
AnswerRe: GridSplitter Behaviour Pin
Pete O'Hanlon4-Jan-10 9:25
mvePete O'Hanlon4-Jan-10 9:25 
GeneralRe: GridSplitter Behaviour Pin
rj_hogan5-Jan-10 0:46
rj_hogan5-Jan-10 0:46 
GeneralRe: GridSplitter Behaviour Pin
Pete O'Hanlon5-Jan-10 2:16
mvePete O'Hanlon5-Jan-10 2:16 
QuestionWWF Pin
Ramkumar_S3-Jan-10 14:36
Ramkumar_S3-Jan-10 14:36 

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.