Click here to Skip to main content
11,641,708 members (60,448 online)
Click here to Skip to main content
Add your own
alternative version

WPF Common TaskDialog for Vista and XP

, 30 Dec 2007 CPOL 143.8K 2.3K 114
WPF custom TaskDialog that renders the same on Vista and XP. This custom dialog simplifies programming by providing a simple interface for developers that is not Operating System dependent. This solution does not use the Windows API for rendering.
customdialogsample-12-30-2007.zip
CustomDialogSample
CommonDialog
CustomDialogInformation.png
CustomDialogQuestion.png
CustomDialogShield.png
CustomDialogStop.png
CustomDialogWarning.png
My Project
Settings.settings
CustomDialogSample
My Project
Settings.settings
customdialogsample.zip
CustomDialogInformation.png
CustomDialogQuestion.png
CustomDialogShield.png
CustomDialogStop.png
CustomDialogWarning.png
Settings.settings
Settings.settings
CustomDialogSample.suo
' Interaction logic for Window1.xaml
Partial Public Class Window1
    Inherits System.Windows.Window

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub btnOne_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnOne.Click
        Dim obj As New CommonDialog.CustomDialog
        obj.AdditionalDetailsText = "These are additional details"
        obj.Buttons = CommonDialog.CustomDialogButtons.OKCancel
        obj.ButtonsDisabledDelay = 5
        obj.Caption = "The buttons are disabled for 5 seconds"
        obj.DefaultButton = CommonDialog.CustomDialogResults.OK
        obj.FooterIcon = CommonDialog.CustomDialogIcons.Information
        obj.FooterText = "This is the footer text"
        obj.InstructionHeading = "This is the instruction heading"
        obj.InstructionIcon = CommonDialog.CustomDialogIcons.Question
        obj.InstructionText = "Do you want to proceed with the next task?"
        Dim objResults As CommonDialog.CustomDialogResults = obj.Show

        Me.tbResults.Text = String.Format("Last dialog result was {0}", objResults.ToString)

    End Sub

    Private Sub btnTwo_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnTwo.Click
        Dim obj As New CommonDialog.CustomDialog
        obj.Buttons = CommonDialog.CustomDialogButtons.YesNoCancel
        obj.Caption = "Standard Dialog - default button No"
        obj.DefaultButton = CommonDialog.CustomDialogResults.No
        obj.InstructionHeading = "This is the instruction heading"
        obj.InstructionIcon = CommonDialog.CustomDialogIcons.Question
        obj.InstructionText = "Do you want to proceed with the next task?"
        Dim objResults As CommonDialog.CustomDialogResults = obj.Show

        Me.tbResults.Text = String.Format("Last dialog result was {0}", objResults.ToString)
    End Sub

    Private Sub btnThree_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnThree.Click
        Dim obj As New CommonDialog.CustomDialog
        obj.AdditionalDetailsText = "You are using a very cool WPF dialog box that works with both Vista and XP"
        obj.Buttons = CommonDialog.CustomDialogButtons.OK
        obj.Caption = "Works with Vista and XP"
        obj.DefaultButton = CommonDialog.CustomDialogResults.OK
        obj.FooterIcon = CommonDialog.CustomDialogIcons.Shield
        obj.FooterText = "This is a secure program"
        obj.InstructionHeading = "Big Brother Is Watching"
        obj.InstructionIcon = CommonDialog.CustomDialogIcons.Warning
        obj.InstructionText = "Do you want to proceed with the next task?"
        Dim objResults As CommonDialog.CustomDialogResults = obj.Show

        Me.tbResults.Text = String.Format("Last dialog result was {0}", objResults.ToString)
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Karl Shifflett
Architect Gayle Manufacturing Company
United States United States
Karl loves .NET, WPF, WCF, ASP.NET, VB.NET and C#.

Awards:

  • December 2008 VB.NET Code Project Article Award
  • 2009 Code Project MVP
  • 2008 Code Project MVP
  • 2008 Microsoft MVP - Client App Dev
  • December 2007 VB.NET Code Project Article Award
  • Gold Medal Winner at IBM's 1998 PROIV Programming Contest in Las Vegas
Click here to check out my Blog

Click here to learn about Mole 2010 debugging tool for Visual Studio 2010

Click here to read about XAML Power Toys

Just a grain of sand on the worlds beaches.


You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150731.1 | Last Updated 30 Dec 2007
Article Copyright 2007 by Karl Shifflett
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid