Windows Scripting
  Home arrow Windows Scripting arrow 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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 2
    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


    (Page 1 of 5 )

    In this conclusion to a four-part series that illustrates WPF through the example of building a to-do list application, we will complete the program we started. You will learn how to make the software handle deleting tasks, and how to give it the look and feel you want.

    Deleting tasks

    Now that a mechanism for the addition of new tasks has been added, the user needs a way to delete an existing task. In the code, deleting tasks is much easier than adding tasks. The element representing the selected task simply needs to be removed from the XML when the user clicks the delete button.

    In Visual Studio, double click the delete button in the designer to automatically create a click event handler, or manually add it:


    <Button Name="DeleteButton" Grid.Row="1" Grid.Column="1" Content="Delete Task" Click="DeleteButton_Click">


    The code for deletion is really simple. First, the code needs to check that an item is indeed selected. If nothing is selected in TaskListBox, then its SelectedIndex property will be -1. So, the code simply needs to check that SelectedIndex isn't -1. If it isn't, then the value of the SelectedItem property of TaskListBox needs to be cast into an XmlElement object, and this element needs to be removed from its parent element (Tasks):


    private void DeleteButton_Click(object sender, RoutedEventArgs e)

    {

     if (TaskListBox.SelectedIndex != -1)

    {

     XmlElement task = (XmlElement)TaskListBox.SelectedItem;

    task.ParentNode.RemoveChild(task);

    }

    }


    When a task is selected and the delete button is pressed, the task will now be deleted from the list.

    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

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek