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

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

TreeView, HierarchicalDataTemplate - How to show sibling collections?

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :WPF

I have an object model (I am using LINQ) that has a HealthCenter as the top level object.  HealthCenter has a Sites collection and a Providers collection. 


Ideally, I want to show this in a TreeView like:


HealthCenter 1


        Site 1


        Site n


        Provider 1


        Provider n


HealthCenter n




I could also live without the Sites and Providers nodes (which are not _really_ part of my objects, just logical) if I had to, as long as I can apply different templates to each type.  So far I've been unable to figure out how to do this.

View Complete Post

More Related Resource Links

How can I show Plus sign(Expand mode) Before treeview item in wpf?

Hi,    We are using tree view control in XBAP,in which I m listing all parent node. But it doesnt show plus sign(For expansion) before node header. We have written code to fetch node's child on ItemChanged event.When I click on node and if its have children its showing plus sign.  Do any body know how to show plus sign regardless of whether that node has child or not? Regards, Mehul

Treeview populated on demand to show the file system - specifying the root

Hi, I am trying to simulate the file system like explorer using a treeview.  I would like to have the application in the server but is the starting root limited to where the application is?  Is it possible to have a certain directory in the server to be the starting node?  I would like to be able to set a starting node in the config.   Thank you. 

How to show label when TreeView is empty?


Sometimes I feel that DataBinding and Triggers defined in xaml is just trying to fight me.

I have this really simple case where I have a UserControl with a TreeView and a TextBlock. I want to show the TextBlock only when the TreeView is empty.

In code this would be one or two lines of code, but I’m determined to hook it up in xaml, but so far, no matter what I try it doesn’t work.


I even tried to expose the Items as a property on the control class itself – but I could bind to that either.


How would you do this in xaml ?





Styling a complex HierarchicalDataTemplate for TreeView

I've got a (reasonably) complex hierarchy that I would like to display in a TreeView. In fact I can quite easily display the hierarchy in a TreeView - the problems start when I want to style those hierachy items.

Let me try to explain the data structure initially:

I have an "organisation" which contains collections of sub-"organisations" and "people".
"People" can contain collections of "items".
"Item" is a leaf node which does not contain any further children.

I make use of the excellent ComplexDataTemplates control library and my TreeView and it's associated HierarchicalDataTemplates is described thus:

      <!-- IEnumerable[OrganisationViewModel] -->
<HierarchicalDataTemplate x:Key="IEnumerable[OrganisationViewModel]" ItemsSource="{Binding Path=.}">
<TextBlock Text="Sub-units" />

<!-- OrganisationViewModel -->
<HierarchicalDataTemplate DataType="{x:Type vm:OrganisationViewModel}">

HierarchicalDataTemplate in TreeView


I'm have the xml file:

    <Interaction DateCreated="633237231760000000" Index="0" InteractionId="EmailOutReply_0000Da3CUJMW003D-15" IsArquived="False" Status="UNKNOWN" Subject="Re: Test Data" Type="EMAIL_OUT_REPLY">
      <Sender Email="make@make.com" Personal="Make Make" />

And I have to show in Treeview this way:

--> DateCreated
        --> Time    Subject    Status
                --> Personal    Sender

--> 08/01/2008
        --> 03:00 PM    Re: Test Data    UNKNOWN
                -->    Make Make    make@make.com
        --> 04:00 PM    Re: Test Data    UNKNOWN
                -->    Make Make    make@make.com
--> 08/02/2008
        --> 05:00 PM    Re: Test Data    UNKNOWN
                -->    Make Make    make@make.com
        --> 06:00 PM    Re: Test Data    UNKNOWN
                -->    Make Make    make@make.com

GridView control to show master-child or master-slave data, written in c#, asp.net

I previously made a master slave datagrid using Visual Studio 2003 .Net (original article) that would allow users to show data to clients using collapse and expand features. These features however did not carry over to gridview for many users. This tutorial will explaing how to create a collapsable/expandable gridview in frameworks 2.0 and higher

Show grand total running total in GridView Footer

In many scenarios we need to display Running total as well as Grand total in GridView footer. In this post i will try to explain in an easy way that how we can display running total & Grand total in a GridView footer combindly. To explain this solution using an example here i use a sales order report. The report contains all sales order amount in a tabular way. I will use a GridView to display sales order amount and use GridView footer to display Running total & Grand total. Let we have a customer table with id and name column plus an orders table with OrderID,CustomerID,OrderDate & Amount. Now our goal is to show all customers order with amount as well as page wise running total & grand total. Note that running total is necessary when you enable paging in a GridView where as Grand total is always you can consider.

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.

datalist image slide show problem


hi friends

i am binding  images dynamically(back end)for a datalist .iam applying a slideshow for it .I am getting a problem to apply slideshow for dyanmically binded images.If the define in a div statically it working perfectly

for example pls go through my code below:

<script type="text/javascript">
$(document).ready(function() {
        fx: 'scrollLeft' // choose your transition type, ex: fade, scrollUp, shuffle, etc...

<div class="slideshow">
        <img src="images/30_dummy.jpg" width="200" height="200" />
        <img src="images/aquarius.gif" width="200" height="200" />
        <img src="images/star.gif" width="200" height="200" />
        <img src="images/the-proud-indian-flag-1.jpg" width="200" height="200" />

I above code works perfectly and the slide show e

create user wizard login error message dont show in a message box?




i am using create user wizard and capturing other information within content template when a new user

registers. Some of the textboxes are binded to required field validators.


there is a validation control on the page and ShowMessage box is True.

If they dont complete some of the text boxes then the message box pops Up with the error message.

It does not however include information errors like "User already exists" or Email address already exists

from the create user wizard membership  UserName and Password Textboxes


is it possilbe to hook all of these up so I get one message box with all errors including membership ones?




Can't get an Icon to show for Desktop shortcut and Program Menu



I've created a SetupWizard, but can't get it to show the Icon for the shortcut on desktop and program menu. The installation goes fine without any errors, the only problem is the icon.

I've made a shortcut of my exe file in the Application Folder and dragged the shortcut to the Desktop folder, then on the shortcut properties, I assigned it an icon picture located in Application Folder.

Any suggestions will be very much appreciated.


Why show only one record?



// Update these variables to values whatever you are storing in your table
        // If you are storing as CARD NUMBER, update this Card Number Attribute Name to CARD NUMBER
        string strCardNumberAttributeName = "Credit card number";
       // string strCardTypeAttributeName = "1";
        string strExpiryDateAttributeName = "Expiry date";
        DataTable dtPaymentDetails = new DataTable();

        string queryString = "SELECT tbl_Payments.PaymentId, tbl_PaymentDetails.AttributeName, tbl_PaymentDetails.Value, tbl_Payments.PaymentType FROM tbl_Payments INNER JOIN tbl_PaymentDetails ON tbl_Payments.ID = tbl_PaymentDetails.PaymentId WHERE ATTRIBUTENAME IN ('" + strCardNumberAttributeName +
                                   "','" + strExpiryDateAttributeName + "') ORDER BY PaymentId";

        string connectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;" +
                                           "AttachDBFilename=|DataDirectory|\\BurnbetDatabase.mdf;User Instance=true";
        using (SqlConnection connection = new SqlConnection(connectionString))
            SqlCommand command = new SqlCommand(queryString, connection);
            SqlDataReader reader = command.ExecuteR

Modify Menu adapter to show selected


Hey, I need some help modifying the menu adapter code to give child <ul> elements a class value indicating that the parent is selected. It should render like this:


< ul class="AspNet-Menu">
	< li class="AspNet-Menu-WithChildren  AspNet-Menu-ChildSelected">
		< a href="/rockit/admin/Default.aspx" class="AspNet-Menu-Link  AspNet-Menu-ChildSelected">
		< span>Mypage< /span>< /a>
			< ul class="AspNet-Sub AspNet-Sub-Selected">
				< li class="AspNet-Menu-Leaf  AspNet-Menu-Selected">
					< a href="/rockit/admin/Default2.aspx" class="AspNet-Menu-Link  AspNet-Menu-Selected">
					< span>Test< /span>< /a>
				< /li>
				< li class="AspNet-Menu-Leaf">
					< a href="/rockit/Default3.aspx" class="AspN

CLR Inside Out: Collections Best Practices


This month Inbar Gazit shows readers how to get the most out of the System.Collections namespace.

Inbar Gazit

MSDN Magazine August 2007

Data Binding: Give Your Everyday Custom Collections a Design-Time Makeover


In this article, Paul Ballard shows how you can provide data binding support for your custom collections to enable sorting, searching, and editing in as simple a manner as possible. In addition, he shows how to make all of these features available in the Windows and Web Forms Designers, just like an ADO.NET DataSet.

Paul Ballard

MSDN Magazine August 2005

Cutting Edge: DataSets vs. Collections


In software, five years is like a geological era. Five years ago, the Microsoft® . NET Framework had just been announced. Since then, the DataSet has emerged as the key object for performing a variety of data-related tasks in .

Dino Esposito

MSDN Magazine August 2005

Cutting Edge: Collections and Data Binding


When it's time to design the Data Access Layer (DAL) of your distributed Microsoft® . NET Framework-based app, one of the key decisions you'll make is how you'll pass data to and from methods of DAL classes.

Dino Esposito

MSDN Magazine May 2005

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