Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - Completing a WPF To-Do List Application
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

Completing a WPF To-Do List Application
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-15

    Table of Contents:
  • Completing a WPF To-Do List Application
  • Saving the task list
  • Stylizing the application
  • Stylizing the application, continued
  • Finishing Up

  • 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


    Completing a WPF To-Do List Application - Saving the task list


    (Page 2 of 5 )

    You've probably noticed that even though tasks can be added to and deleted from the list, the changes are erased when the program is closed. This is because with an XML data source, the binding really only goes one way. Any changes are actually only saved to an in-memory XML document, not the original source file.

    However, it's not very difficult to work around this. We simply need to add code that writes the in-memory document to the physical XML file. Perhaps the easiest way to do this is to write the changes when the application is closed, although a more complex system would be better in a real application.

    In the XAML for Window1, add an attribute pointing to a handler for the Closing event:


    <Window x:Class="WpfToDo.Window1"

     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

     xmlns:local="clr-namespace:WpfToDo"

      Closing="Window_Closing"

     Title="To-Do List" SnapsToDevicePixels="true" Height="480" Width="384">


    The code for this handler is pretty straightforward. The XmlDataSource needs to be fetched, and the XML document needs to be saved on disk:


    private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)

    {

     XmlDataProvider tasks = (XmlDataProvider)FindResource("tasks");

    tasks.Document.Save("Tasks.xml");

    }


    Now changes to the application will be saved when the main window is closed, and, functionally, the application is complete.

    More Windows Scripting Articles
    More By Peyton McCullough


       · Hello, all,In this article, which is the last of a four-part series, we finish...
       · This was a great article for some basics in WPF, will the source code be provided...
     

    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 4 hosted by Hostway
    Stay green...Green IT