.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How can I handle the loaded events for all TreeViewItems in a TreeView?

Posted By:      Posted Date: September 04, 2010    Points: 0   Category :WPF
I have a custom control that inherits from the TreeView control. Here's the code I have right now:   public ModdedTreeView() { this.AddHandler(TreeViewItem.LoadedEvent, new RoutedEventHandler(ItemLoaded)); } protected void ItemLoaded(object sender, RoutedEventArgs e) { TreeViewItem item = e.OriginalSource as TreeViewItem; } Unfortunately my handler seems to be handling the TreeView loaded event instead of the TreeViewItem loaded event. The original source is always the TreeView.   What is going wrong?

View Complete Post

More Related Resource Links

COM: Handle Late-bound Events within Visual Basic Using an ATL Bridge


Since a Visual Basic client doesn't handle events directly from late-bound COM objects, it needs some way to capture all the events and parameters launched by any COM object server instantiated at runtime and not known at design time. This article explains how to build a bridge component that does just that. The bridge component transmits the intercepted event data back to the Visual Basic client using another supporting COM object that is capable of holding event data and attributes. The Visual Basic client receives the notification from the bridge and extracts all the information relative to the event from the supporting object.

Carlo Randone

MSDN Magazine March 2001

How to make a TreeView custom ItemsSource behave like normal TreeViewItems?


I have made a custom class to populate a TreeView thru its ItemsSource. That class heritates ObservableCollection.

The thing is that its nodes doesnt seem to be TreeViewItems because i cant apply code that works for normal treeviewitems.

I'm talking about code to do right click select, etc.

Can somebody tell me how can i solve this problem?



How to handle treeview selected node changed event



From my below sample code, I don't want to use Sessions to handle each click event inside treeview selected node changed.

Secondly, if you suggest me to use treenode.SelectedValue then I would say my values are dyanmically generated.

Everytime a node a clicked, the selected node value is sent in the next request xml to get response and xml schema is different for each click. How do I handle this each click event other than using session variables. I thought of using Request.Item (and integrating with URL redirect property) but I don't want to use that.


Dim trNode As New TreeNode
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then        
            trNode.Text = "Not Postback"
            Session("Flag") = 1
        End If
    End Sub

Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TreeView1.SelectedNodeChanged
        If Session.Item("Flag") = 1 Then
            trNode.Text = "Is PostBack"
            Session("Flag") = 2
        End If

Can the WorkflowRuntime host handle events raised by a WorkflowInstance?


Or basically, can a workflow instance send a message to the host?

I've spent the better part of a week trying to determine if this is even possible. My searching hasn't turned up too many examples of this and the ones I've seen do not seem to work. The few examples I found suggest using a CallExternalMethodActivity to the external data exchange service, which then raises an event that the host is subscribed to (as seen here ).

Below is my simplest attempt at achieving this:

class Program
    static void Main(string[] args)
      using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
        AutoResetEvent waitHandle = new AutoResetEvent(false);
        workflowRuntime.WorkflowCompleted += 

Gridview with LinkButtons to handle events that update AjaxUpdatePanel


I have a Gridview displaying Titles.

I would like those titles to be LinkButtons that would cause event to update an AJAX UpdatePanel containing details about the Projects.

I would not like the Gridview to be in the Ajax UpdatePanel and refresh on every click, rather just refresh the UpdatePanel.

Can someone direct me in a direction to achieve this?

Group events and dynamically loaded user control


My main file is messages.aspx and i am loading a UC names message_inbox.ascx dynamically as:

SiteUserControls_Message_MessageInbox    InboxUC = Page.Load("message_inbox.ascx") as


Now in my user control ("message_inbox.ascx") i have a various events which i am combining in one group event :

 public void ForwardLinkButton_OnClick(object sender, EventArgs e)
        LinkButton thisButton = (LinkButton)sender;

How to handle login control events when using a custom FBA login page?


Thanks to Kirk Evans' blog post that is liberally referenced all over the place, I have managed to get a custom login page working on my SP2010 site and it is pretty great.  The problem that I am having is that there doesn't seem to be anyway to respond to the events that are raised by asp.net login control that is in my page.

The page is inherited from Microsoft.SharePoint.IdentityModel.Pages.FormsSignInPage and as a result will error out when I attempt to reference a code-behind .cs file.  My question is, how do I respond to the events being raised by the login control that is in the page so that I can do things like logging successful user sign-ins?

Joseph Ackerman, MCSD, MCP.Net

WCF Tutorial - Events and Callbacks

we described how to make a very simple client/server application where clients would call functions on the server through a shared interface. In this tutorial, I'm going to expand that application to allow the server to execute functions on the client by using callbacks. Essentially, this is WCF's mechanism to allow events to be raised from the server to it's connected clients.

Delegates and events in c#.net

People often find it difficult to see the difference between events and delegates. C# doesn't help matters by allowing you to declare field-like events which are automatically backed by a delegate variable of the same name. This article aims to clarify the matter for you. Another source of confusion is the overloading of the term "delegate". Sometimes it is used to mean a delegate type, and at other times it can be used to mean an instance of a delegate type. I'll use "delegate type" and "delegate instance" to distinguish between them, and "delegate" when talking about the whole topic in a general sense.

How to listen to events within a listview



I've got a listview and I've put a button control in one of the columns, I'm trying to figure out how I have listen to the button click within a certain row, but can't see the button in the dropdown for the IDs I can generate events for.

I'd like to get the primary key of the row that's been clicked on and then run a sql statement against it.

Any help would be appreciated.

JQuery Treeview plugin is not working with Ajax page load in ie8


Hi there,

I developed a page where i m using jquery treeview plugin to generate tree. It worked fine on FF, IE8 with out ajax.

But when my page loads thro' ajax call in IE8, it is not collapsing or expanding tree.

Any idea?

Thanks in advance.

An endpoint configuration section for contract 'xxx' could not be loaded because more than one end



I'm trying to test calling a webservice, I've found several free ones on http://webserviceshare.com, but none of them work for me.  Some of them give example calling code in C# which I've translated to VB.NET, they're typically just two to four lines, I don't think I've translated them incorrectly.

On that I've tried is US Zip Validator.  I added a Service Reference to http://www.webservicemart.com/uszip.asmx?WSDL, called ZipService.

I then call it like so:

            Dim myZipService As ZipService.USZipSoapClient = New ZipService.USZipSoapClient()
            Dim myCity As String = myZipService.ValidateZip("27707")

I get the following error on the first line of code:

"An endpoint configuration section for contract 'ZipService.USZipSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name."

A page with information on this web service (including C# source code) is at:


UI Frontiers: Multi-Touch Manipulation Events in WPF


Multi-touch has progressed from being a futuristic prop of sci-fi films to a mainstream means of user interface. We'll show you how support for multi-touch in Windows 7 has filtered down and settled into various areas of the .NET Framework.

Charles Petzold

MSDN Magazine August 2010

Event Tracing For Windows: Core Instrumentation Events in Windows 7, Part 2


In Part 2, the authors cover core OS Event Tracing for Windows (ETW) events as well as present simple scripts to demonstrate a few basic accounting techniques on some of the OS events introduced.

Alex Bendetov, Insung Park

MSDN Magazine October 2009

Event Tracing for Windows: Core Instrumentation Events in Windows 7


In the first article of a two-part series, the authors present a high-level overview of the ETW technology and core OS instrumentation.

Alex Bendetov, Insung Park

MSDN Magazine September 2009

Advanced WPF: Understanding Routed Events And Commands In WPF


See how routed events and routed commands in Windows Presentation Foundation form the basis for communication between the parts of your UI.

Brian Noyes

MSDN Magazine September 2008

Transactions: Build Scalable Systems That Handle Failure Without Losing Data


Systems that handle failure without losing data are elusive. Learn how to achieve systems that are both scalable and robust.

Udi Dahan

MSDN Magazine July 2008

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend