August 2005 Entries
Introducing Microsoft Windows Presentation Foundation (Avalon)
Windows Presentation Foundation (formerly code named Avalon) is the Microsoft unified presentation subsystem for Windows, consisting of a display engine and a managed-code framework. Windows Presentation Foundation unifies how Windows creates, displays, and manipulates documents, media, and the user interface, enabling developers and designers to create visually stunning, personalized user experiences that improve the application connection with the user.
XAML, a markup language to represent user interfaces declaratively for Windows applications, will also be introduced with Windows Presentation Foundation, improving the richness of the tools for composing and repurposing user interfaces. For Web developers, XAML provides a familiar UI description paradigm. XAML also enables the separation of UI design from the underlying code, enabling developers and designers to work more closely.
Using XAML, Creating a Button is as simple as
<Button Width="100"> OK
As we can see, XAML extends the power of XML and makes declarative programming which is very useful for reducing the amount of work done currently for server side programming.
Also, you can attach events to the XAML Button and have an associated Codebehind in C# or VB.NET, whatever may be
<Button Click="Button_Click">Click Me!</Button>
C# code-behind file
void Button_Click(object sender, System.Windows.Controls.ClickEventArgs e)
btn1.Background = System.Windows.Media.Brushes.Red;
For developers and designers, Windows Presentation Foundation provides a unified UI platform, such that they can learn a single paradigm which provides limitless possibilities of UI experiences.
Avalon leverages on WinFX which is the next set of APIs which will be available in Windows Vista (Longhorn) and the power of XAML to render powerful rich graphics to improve the user experience.
More information can be found at
Create the Experience
Windows Presentation Foundation and Windows Vista surely will provide a new experience of Development / Usability for the years to come.
Share This Post:
Treeview - XML, XPATH - Show part of XML Document
Treeview is one of the important controls being used in applications to improve the usability experience for users for displaying Hierarchial Data.
ASP.NET 1.x versions did not ship with a built-in treeview control as a part of the Web Controls. However Microsoft did release a set of UI Controls including the Treeview, Tabstrip Control etc., collectively called as Microsoft IE Webcontrols.
Though Microsoft doesnt support these controls currently (as mentioned in their MSDN Documentation), those controls do provide a great resource for developing web applications with rich user experience.
Treeview is one such component which is very useful in representing Hierarchial Data (mostly based on XML structure).
Whidbey (ASP.NET 2.0) does come with a built-in TreeView control, Menu Control etc.,which are part of the current IE Webcontrols and I guess that much be one of the reasons for Microsoft to stop supporting the existing IE Webcontrols which have a lot of limitations.
However, even with the current TreeView control we can very well utilize the Hierarchial structure of representing data.
You can bind a Treeview to an XML Document (which is a common practice since XML is again a hierarchial data representation). But with the current Treeview control, the XML needs to adhere to certain standards.
The Root Node must be <TREENODE> and it MUST be in Caps. Otherwise, it would raise a
"did not contain the required outer <TREENODES> container. "
The Node elemets much start with the element name <treenode> and must have the attribute Text which is the text displayed in the TreeView Node. You can as well enhance the look and feel by specifying ImageURL, CheckBox, NavigateURL etc.,
However, on some occasions we would like to show only a portion of the XML Document. Say you want to show only certain set of Nodes based on a condition. An xml document may contain a lot of nodes from which we would like to display particular nodes. That is a little tricky since you need an XML file with the strucutre as explained above for the TreeView to display properly.
I give herebelow the steps involved in selecting particular nodes of an XML Document to display in TreeView. I am using XPATH to select particular set of nodes. If you are unfamiliar with XPATH, it is a W3C Standard for querying and retrieving XML Data from XML Documents. XPATH is fully supported in .NET and there are lots of classes and methods provided with XPATH to navigate and query XML Documents. More information on XPATH and an excellent Tutorial can be found at
Let us consider the following XML Tailored to suit the format required for TreeView
<treenode Text="Books" ID="1" Category="Fiction">
<treenode Text="Look Into Future" ID="1"/>
<treenode Text="What Tomorrow would be?" ID="1"/>
<treenode Text="Books" ID="1"/>
<treenode Text="Books" ID="2" Category="History">
<treenode Text="American History" ID="1"/>
<treenode Text="Indian History" ID="1"/>
<treenode Text="Japanese History" ID="1"/>
<treenode Text="UK History" ID="1"/>
<treenode Text="Books" ID="3" Category="Cartoon">
<treenode Text="Tom and Jerry" ID="1"/>
<treenode Text="Mickey Mouse" ID="1"/>
<treenode Text="Donald Duck" ID="1"/>
<treenode Text="Books" ID="4" Category="Mystery">
<treenode Text="Da Vinci Code" ID="1"/>
<treenode Text="The Wheels" ID="1"/>
<treenode Text="Chasing a Crooked Shadow" ID="1"/>
We will save the above file as "Books.XML". Note that the above XML already has the relevant format for binding to the TreeView as per its requirement. We will see in future articles on how to transform a generic XML format into one required for the TreeView as above.
Now, the code to select only Books of Category "Mystery" and display in the TreeView.
StringWriter sWriter = new StringWriter();
// Creating a String Writer object
XmlTextWriter xWriter = new XmlTextWriter(sWriter);
// Creating a Xml Writer object
XmlDocument xDoc = new XmlDocument();
//Loading the original XML Document
XmlElement xRoot = xDoc.DocumentElement;
// Creating the Root Element.
string xPathExpr = "//treenode[@ID=4]/descendant-or-self::*";
// XPATH Expression to select specific nodes.
XmlNode xNode = xRoot.SelectSingleNode(xPathExpr);
//Selecting the Node which is the parent node matching the XPATH Expression
if(xNode != null)
XmlDocument xNewDoc = new XmlDocument();
//Creating a Dynamic XML to attach the TREENODE Element to the specific node set.
XmlNode xImpNode = xNewDoc.ImportNode(xNode, true);
//Creating and importing the Node from the original XML Document. The
value indicates, all the child nodes for this node will be selected.
//Appending the Nodes Imported to the Dynamic XML Document.
//Writing the Appended Nodes to the XML Writer
TreeView1.TreeNodeSrc = sWriter.ToString();
//Assigning the TreeNodeSrc property with the StringWriter which contains the XmlText
Though for simplicity I have a 2 level Hierarchy XML Structure, the above code would select all TreeNode elements having attribute ID with the value 4 irrespective of where the Nodes are there in the Tree Hierarchy ie., even if there are child nodes containing Book Details, they will also be selected to give the Tree structure (Parent - Child - Child structure)
This would facilitate in showing only specific portion of an XML which is currently difficult to implement with the IE Webcontrols.
As already explained, this has been much more simplified in ASP.NET 2.0 (Whidbey) which ships with a built-in TreeView control containing a property to specify the XPATH Expression for selecting specific nodes.
Cheers and Happy Tree Viewing !!!
Share This Post:
You may receive the error: "The underlying connection was closed: Unable to connect to the remote server." while consuming a Webservice
You may receive the error "The underlying connection was closed: Unable to connect to the remote server." while trying to consume a Web Service from your ASP.NET Web Application. However, the same Web Service can be consumed from a Windows Application without any issues.
This error particularly occurs if you are behind a firewall or proxy. When you use a winforms app, it can autodetect the proxy using IE settings for current user, and it can connect out through the proxy. However, when in asp.net, it cannot because the asp.net user identitiy does not have the correct proxy settings.
To resolve this issue, you need to explicitly specify the proxy settings for your application. You can do it at various levels viz., at the Machine.Config file which will apply for all the applications running on the system, at the Web.Config file such that it applies for a single application, and at the Page Level programattically in the code behind / code inline.
usesystemdefault = "false"
For Machine.Config use the same settings as above.
To do it programmatically,
WebServiceClass MyWebServiceClass = new WebServiceClass();
WebProxy proxyObject = new WebProxy("http://address:port", true);
MyWebServiceClass.Proxy = proxyObject;
where WebServiceClass is the name of the Web Service Class which you are consuming.
That should solve the issue with consuming the Web Service across Proxy Settings.
Cheers and Happy Web Servicing !!!
Share This Post:
India MVP Nominations - Now Open !!!
Good news for Technology Experts and Community Crackers. The Nomination Cycle for MVP Program for this quarter is now open.
Microsoft Most Valuable Professional
for more information.
For those who are new to MVP Program,
Each year, Microsoft gives out an award called the Microsoft MVP (Most Valuable Professional) Award to outstanding members of a Microsoft online Developer Forum. The MVP Award is given in recognition of a recipient's technical expertise, spirit of community, and their willingness to help their peers by providing reliable and accurate answers to technical questions about Microsoft products & technologies.
So, if you are a person who is passionate to help others in online forums, communities and have the expertise to solve easy to complex queries posted by 1000s of people in the discussion forums and guide them through to solution, you can nominate yourself for the program.
It is a honor to be an MVP and is certainly a great recognition from Microsoft for those sparkling talented professionals who take the extra effort to exceed and help their peers.
For more information on benefits and to nominate, please check
Cheers and Best Wishes for your Nominations !!!
Share This Post:
Configuring Fiddler for Windows 8 Apps
about 531 days ago
Continuing the Windows 8 vision with Windows 8.1
about 540 days ago
hey Jon! any update on when the
vNext refresh would come?
about 543 days ago
Virtual Machine and Cloud Service Sizes for Windows Azure
about 543 days ago
Hi, does MuPDF work for Windows Phone 8?
about 549 days ago
Do you know if it works for Windows Phone 8 also?
about 549 days ago
Configuring a custom domain name for a Windows Azure web site https://t.co/p073z2fsm6
about 557 days ago
Accessing WCF Service from Windows Store App
about 557 days ago
Identity & Access VSIX Extension for Visual Studio 2012
about 560 days ago
thanks Karthik! It was nice to see you at GIDS
about 560 days ago
September 2013 (1)
April 2013 (2)
March 2013 (1)
February 2013 (1)
December 2012 (1)
June 2012 (2)
April 2012 (2)
February 2012 (2)
January 2012 (3)
December 2011 (4)
November 2011 (3)
October 2011 (6)
September 2011 (7)
August 2011 (3)
July 2011 (2)
June 2011 (6)
May 2011 (2)
March 2011 (5)
February 2011 (2)
January 2011 (1)
October 2010 (2)
September 2010 (2)
July 2010 (4)
May 2010 (5)
April 2010 (1)
March 2010 (2)
February 2010 (2)
January 2010 (2)
December 2009 (7)
November 2009 (1)
October 2009 (2)
September 2009 (7)
August 2009 (5)
July 2009 (6)
June 2009 (4)
May 2009 (11)
April 2009 (4)
March 2009 (6)
February 2009 (4)
January 2009 (5)
December 2008 (5)
November 2008 (4)
October 2008 (9)
September 2008 (5)
August 2008 (4)
July 2008 (2)
June 2008 (2)
April 2008 (3)
March 2008 (1)
February 2008 (8)
January 2008 (8)
December 2007 (5)
November 2007 (5)
October 2007 (2)
August 2007 (3)
July 2007 (5)
June 2007 (4)
May 2007 (14)
April 2007 (3)
March 2007 (3)
February 2007 (8)
January 2007 (8)
November 2006 (9)
October 2006 (5)
September 2006 (1)
August 2006 (1)
June 2006 (2)
May 2006 (2)
April 2006 (2)
March 2006 (2)
February 2006 (4)
January 2006 (5)
December 2005 (7)
November 2005 (4)
October 2005 (3)
September 2005 (9)
August 2005 (4)
July 2005 (6)
June 2005 (7)
May 2005 (11)
April 2005 (42)
XAML Mood Wheel / Spinner Wheel Control for Windows 8/Store Apps
TechEd India Data: Exposing Azure Mobile Services through Web API
Updated Windows Blog Reader Sample with Background Task
Charting in Windows 8 Store Apps
ASP.NET SignalR “SCRIPT5007: Unable to get property 'client' of undefined or null reference” error
Hi,I am not able to load the Paypal website Using ...
best writing service for educational or profession...
A very cool look at a product I'm currently intere...
so where do we paste the code that you provided??H...
Content Copyright © 2014 Harish Ranganathan