Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Select hidden treeviewitem in databound treeview

 
 
Old 01-31-2006   #1 (permalink)
RyanLeeSchneider


 
 

Select hidden treeviewitem in databound treeview


I'm having an issue selecting a databound treeview item in a treeview.

If the treeview has not already been expanded, then the treeviewitems don't
exist, so the code:

TreeViewItem tvi =
(TreeViewItem)(header.ItemContainerGenerator.ContainerFromItem(databoundobject));

returns null.

If I do:

header.IsExpanded = true;

before the call, the UI isn't updated (and the items bound) until after my
method returns, so I still get null (but the treeview is expended after my
method returns).

So, I tried using a WorkItem to expand on another thread:

if(header.IsExpanded == false)
{
header.IsExpanded = true;
//we have to queue a workitem since we have to wait for
the header to expand

System.Threading.ThreadPool.QueueUserWorkItem(ExpandedToSelectProcessWorkItemCallback, databoundobject);
}

However, then my callback throws a InvalidOperation exception because I'm
accessing the treeview on another thread.

So, I dug around and found people talking about the UIContext in this NG,
but I can't find any mention of it in the Dec CTP.

So, my question is:

-What's the best way to expand the treeview before searching it? (Please
don't say animations, please don't say animations.. )
-Bonus Question: what's the equivalent of UIContext in the Dec CTP?


My System SpecsSystem Spec
 

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46