Click here to Skip to main content
15,926,174 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: WPF Drag & Drop Pin
RugbyLeague31-Mar-11 6:00
RugbyLeague31-Mar-11 6:00 
GeneralRe: WPF Drag & Drop Pin
Kevin Marois31-Mar-11 6:01
professionalKevin Marois31-Mar-11 6:01 
AnswerRe: WPF Drag & Drop Pin
Abhinav S31-Mar-11 22:26
Abhinav S31-Mar-11 22:26 
QuestionTreeView Pin
RugbyLeague31-Mar-11 5:54
RugbyLeague31-Mar-11 5:54 
AnswerRe: TreeView [modified] Pin
SledgeHammer0131-Mar-11 6:29
SledgeHammer0131-Mar-11 6:29 
GeneralRe: TreeView Pin
Pete O'Hanlon31-Mar-11 6:43
mvePete O'Hanlon31-Mar-11 6:43 
GeneralRe: TreeView Pin
RugbyLeague31-Mar-11 12:14
RugbyLeague31-Mar-11 12:14 
GeneralRe: TreeView [modified] Pin
SledgeHammer0131-Mar-11 12:50
SledgeHammer0131-Mar-11 12:50 
Ok, no problem. Dealing with item based controls in WPF is kind of a PITA because... Well, lets say you are binding to a collection of type Widget. So part of the tree control interacts with objects of type Widget, and other stuff you need to do is in the wrapping type TreeViewItem. TreeViewItem wraps your Widget class. One tricky aspect that kills a lot of people is that the TreeViewItem item that wraps a specific Widget doesn't exist all the time and randomly changes instances (like when the visual goes off screen).

In your case, you want to set the TreeViewItem.IsExpanded and the TreeViewItem.IsSelected.

You use ItemContainerGenerator.ContainerFromItem(widget) to go from a Widget to a TreeViewItem, but as I said above, the TreeViewItem don't exist all the time and comes and goes. So you have to subcribe to the ItemContainerGenerator.StatusChanged event to know when you can access the TreeViewItem.

What a lot of people do is add IsExpanded and IsSelected properties to the Widget object and in the XAML bind the Widget IsExpanded to the TreeViewItem.IsExpanded. The two properties in Widget either need to be dependency properties or Widget needs to implement INotifyPropertyChanged.

That way you will ALWAYS have access to the two properties and you just set / get them in your Widget object.

modified on Friday, April 1, 2011 1:17 AM

GeneralRe: TreeView Pin
RugbyLeague31-Mar-11 21:17
RugbyLeague31-Mar-11 21:17 
GeneralRe: TreeView Pin
RugbyLeague31-Mar-11 22:17
RugbyLeague31-Mar-11 22:17 
GeneralRe: TreeView Pin
RugbyLeague31-Mar-11 23:02
RugbyLeague31-Mar-11 23:02 
GeneralRe: TreeView Pin
SledgeHammer011-Apr-11 4:47
SledgeHammer011-Apr-11 4:47 
GeneralRe: TreeView Pin
RugbyLeague1-Apr-11 4:48
RugbyLeague1-Apr-11 4:48 
GeneralRe: TreeView Pin
RugbyLeague1-Apr-11 1:36
RugbyLeague1-Apr-11 1:36 
GeneralRe: TreeView Pin
RugbyLeague1-Apr-11 2:52
RugbyLeague1-Apr-11 2:52 
AnswerRe: TreeView Pin
Abhinav S31-Mar-11 22:28
Abhinav S31-Mar-11 22:28 
GeneralRe: TreeView Pin
RugbyLeague31-Mar-11 22:33
RugbyLeague31-Mar-11 22:33 
QuestionPass values between navigatioin or user control pages Pin
arkiboys31-Mar-11 4:46
arkiboys31-Mar-11 4:46 
AnswerRe: Pass values between navigatioin or user control pages Pin
Pete O'Hanlon31-Mar-11 5:02
mvePete O'Hanlon31-Mar-11 5:02 
GeneralRe: Pass values between navigatioin or user control pages [modified] Pin
arkiboys31-Mar-11 5:07
arkiboys31-Mar-11 5:07 
GeneralRe: Pass values between navigatioin or user control pages Pin
Pete O'Hanlon31-Mar-11 5:32
mvePete O'Hanlon31-Mar-11 5:32 
GeneralRe: Pass values between navigatioin or user control pages Pin
arkiboys31-Mar-11 5:36
arkiboys31-Mar-11 5:36 
GeneralRe: Pass values between navigatioin or user control pages Pin
Pete O'Hanlon31-Mar-11 5:50
mvePete O'Hanlon31-Mar-11 5:50 
GeneralRe: Pass values between navigatioin or user control pages Pin
arkiboys31-Mar-11 5:52
arkiboys31-Mar-11 5:52 
QuestionBind current listbox selection to string property in parent window [modified] Pin
Jean-Louis Leroy31-Mar-11 2:45
Jean-Louis Leroy31-Mar-11 2:45 

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.