Click here to Skip to main content
15,912,932 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: System.Exception in K2 Service Manager. Pin
Pete O'Hanlon7-Jan-10 9:17
mvePete O'Hanlon7-Jan-10 9:17 
Question3D Rotation Pin
sajib_bd7-Jan-10 6:04
sajib_bd7-Jan-10 6:04 
QuestionBind to Single Element in Itemssource Using XAML Pin
C.J.7-Jan-10 5:42
C.J.7-Jan-10 5:42 
AnswerRe: Bind to Single Element in Itemssource Using XAML Pin
Abhinav S7-Jan-10 5:59
Abhinav S7-Jan-10 5:59 
GeneralRe: Bind to Single Element in Itemssource Using XAML Pin
C.J.7-Jan-10 6:04
C.J.7-Jan-10 6:04 
GeneralRe: Bind to Single Element in Itemssource Using XAML Pin
Abhinav S7-Jan-10 6:16
Abhinav S7-Jan-10 6:16 
GeneralRe: Bind to Single Element in Itemssource Using XAML Pin
C.J.7-Jan-10 6:47
C.J.7-Jan-10 6:47 
QuestionWPF Datagrid Style Pin
reibor6-Jan-10 10:12
reibor6-Jan-10 10:12 
AnswerRe: WPF Datagrid Style Pin
Mark Salsbery6-Jan-10 12:37
Mark Salsbery6-Jan-10 12:37 
QuestionArgghh my controls are disabled and cannot figure out why!!! Pin
Michael Eber6-Jan-10 9:26
Michael Eber6-Jan-10 9:26 
AnswerRe: Argghh my controls are disabled and cannot figure out why!!! Pin
Ian Shlasko7-Jan-10 3:09
Ian Shlasko7-Jan-10 3:09 
GeneralRe: Argghh my controls are disabled and cannot figure out why!!! Pin
Michael Eber7-Jan-10 7:47
Michael Eber7-Jan-10 7:47 
GeneralRe: Argghh my controls are disabled and cannot figure out why!!! Pin
Ian Shlasko7-Jan-10 10:35
Ian Shlasko7-Jan-10 10:35 
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 

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.