Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

How to add images/icons  in  WPF Tree View from code behind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DNB - 15 Feb 2008 19:50 GMT
How to add images/icons  in  WPF Tree View from code behind

Following is my WPF code, can someone guide me how can I add images from
codebehind

<TreeView Grid.Row="2" FontFamily="Courier" FontSize="14" Name="tree"
TreeViewItem.Selected="TreeView_ItemSelected"
TreeViewItem.Expanded="TreeView_ItemExpanded" >

</TreeView>

<TreeViewItem FontFamily="Courier" Foreground="Red" Background="Yellow"
FontSize="14" />

....

TreeViewItem Newitem = new TreeViewItem();

Newitem.Tag = cNodeSite + u.SiteID.ToString();

Newitem.Header = u.SiteName.ToString();

Newitem.Foreground = System.Windows.Media.Brushes.Green;

Newitem.Items.Add("*");

item.Items.Add(Newitem);

tree.Items.Add(item);

....

....

Thanks

DNB
Nicholas Paldino [.NET/C# MVP] - 15 Feb 2008 21:47 GMT
DNB,

   Look at the Header property or the HeaderTemplate property (depending on
how you want to effect the TreeViewItem).   TreeViewItem derives from
HeaderedItemsControl which has the item to display, and its children.  In
this case, you want the Header.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> How to add images/icons  in  WPF Tree View from code behind
>
[quoted text clipped - 33 lines]
>
> DNB

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.