Solved

programmatically select and expand treeviewItem when bound to a collection

Posted on 2010-11-07
3
1,186 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 500 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now