Solved

programmatically select and expand treeviewItem when bound to a collection

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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