Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

programmatically select and expand treeviewItem when bound to a collection

Posted on 2010-11-07
3
Medium Priority
?
1,202 Views
Last Modified: 2013-11-12
I have a treeview which is bound to an observable collection.
After I insert an element in the collection it appears in my treeview.
Since the collection is of base type INotifyPropertyChanged the treeview methods are no longer available.
I want to be able to set "IsSelected" from code behind.
What is the best way to do this?
0
Comment
Question by:deeMvee
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
incerc earned 2000 total points
ID: 34082943
Hi,

You might want to take a look on the following article :
http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx

Directly related to your question, use Setter.Property, as seen in the "User Interface" part of the above mentioned article:

<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />

0
 

Author Comment

by:deeMvee
ID: 34083374
Hi, and thanks for your reply,

It look like the setter binding is only supported in WPF... And did not mention that I used SL4 in the above question. This method would do what I wanted. I looked at some other posts with work around but they seem very complicated...

Do you have any other sources of help that could tell me how ?
0
 
LVL 4

Expert Comment

by:incerc
ID: 34083743
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Screencast - Getting to Know the Pipeline

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question