Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - Adding Controls to an Application with WPF
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Adding Controls to an Application with WPF
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-02

    Table of Contents:
  • Adding Controls to an Application with WPF
  • Creating the XML data file
  • Databinding
  • Working with templates

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Adding Controls to an Application with WPF - Creating the XML data file


    (Page 2 of 4 )

    The controls are positioned correctly, and now we can turn our attention to the tasks in the to-do list. Obviously, the tasks need to be drawn from some data source. Although there are several options available, the easiest way to store and retrieve the data is through a simple XML file. Preparing this file won't require a lot of work, and the result will be readable and manageable.

    Each task needs to have a name, a description, a priority, and a status (done or not done). Describing this in XML is very easy. Each task can be represented by a Task element, and inside of each Task element can be elements to describe the properties just listed. So, the XML to describe the task of watering flowers might look something like this:

    <Task>

    <Name>Water Flowers</Name>

    <Priority>Medium</Priority>

    <Done>No</Done>

    <Description>

    The flowers need to be watered, or else they'll die.

    </Description>

    </Task>

    As you can see, we haven't opted for anything complex. We're only making a simple to-do list.

    Go ahead and add a new XML file to the project. Name it Tasks.xml and fill it with some tasks:

    <?xml version="1.0" encoding="utf-8" ?>

    <Tasks>

    <Task>

    <Name>Water Flowers</Name>

    <Priority>Medium</Priority>

    <Done>No</Done>

    <Description>The flowers need to be watered, or else they'll die.</Description>

    </Task>

    <Task>

    <Name>Eat Breakfast</Name>

    <Priority>High</Priority>

    <Done>Yes</Done>

    <Description>It's the most important meal of the day.</Description>

    </Task>

    <Task>

    <Name>Buy More Ink</Name>

    <Priority>Low</Priority>

    <Done>No</Done>

    <Description>It'll be out eventually.</Description>

    </Task>

    </Tasks>

    By default, the XML file is a resource. This means that the file will be included in the application's resulting assembly. This isn't what we want. In order for the application to function properly, the XML file needs to exist alongside the assembly. That way, it can be modified. To fix this, select the file, and in the Properties Window, change Build Action to Content and Copy to Output Directory to Copy if newer:



    This will allow everything to work as intended.

    More Windows Scripting Articles
    More By Peyton McCullough


       · Hello, all,This is the second part of my series introducing WPF through an...
     

    WINDOWS SCRIPTING ARTICLES

    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...
    - Modifying XML Files in WSH
    - Reading XML Files in WSH
    - Visual Basic 2005 XML Programming Using XML ...
    - Creating an XML Document in WSH
    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT