Creating a WPF project from scratch

Lets create a WPF Project from scratch, i mean really from the scratch.
Lets begin.

Step 1 :  First create an empty project.
Step 2 :  Add the following DLL reference in your project.
              Presentation Framework
              Presentation Core
              Windows Base
              System.xaml

             This is better shown below. Click on it to enlarge.


Step 3 : Add two New classes to your project
            App.cs
            MyWindow.cs 

The MyWindow.cs class is your custom window and this will extend the base class window. when you run your application this is the window we will see. Please note that there is no xaml window declaration and please do not get confused by reference to the system.xaml dll. we will make use of this in our next example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//Add these namespaces
using System.Windows;
using System.Windows.Controls;

namespace WPFAppFromScratch
{
    //This will be your custom window class which is derieved    
    //from the base class Window.
    class MyWindow : Window
    {
        //Declare some UI controls to be placed inside the
        //window.
        Button _searchButton;
        TextBox _searchTextBox;

        //The controls can be placed only inside a panel.
        StackPanel _panel;

        public MyWindow()
        {
            //This is created just to show a reference , the 
            //below code can aswell be witten wihin this     
            //constructor.
            InitializeComponent();
        }

        void InitializeComponent()
        {
            _searchButton = new Button { Height = 30, Width = 100,  Content = "Search" };
            _searchTextBox = new TextBox{  Height = 30, Width = 100 };

            _panel = new StackPanel();

            //Add the controls inside the panel.
            _panel.Children.Add(_searchButton);
            _panel.Children.Add(_searchTextBox);

            //Set this panel as the content for this window.
            this.Content = _panel;
        }
    }
}

The Code will look something like this on your IDE.


Step 4 : Now Open the file App.cs and type the below code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace WPFAppFromScratch
{
    class App
    {
        [STAThread]
        static void Main()
        {
            //Create an instance of your window.
            MyWindow _window = new MyWindow();

            //Create an instance of a new Application
            System.Windows.Application _wpfApplication = new System.Windows.Application();

            //Run this Application by passing the window object 
            //as the argument
            _wpfApplication.Run(_window);
        }

    }
}


Be sure to add the STAThread attribute on top of your main function. The WPF applications are of Single Threaded Apartment type and if you do do not add this attribute , you will get an exception. Go ahead and try debugging  

System.Windows.Application _wpfApplication = new System.Windows.Application();

Will instantiate a new Application , and passing a Window object to its Run() method will start the application with that Window.

The File will look something like this 


Step 5 : Now right click on the project the click on properties. Here in the Applications tab set the output type of the project to Windows Application  as shown below.


Step 6 : All done. you are good to go now. click on debug and you will see this below window.




This window is your own custom window. Congrats , you just created a WPF project from scratch..


81 comments:

  1. Hello,
    Appreciate your work, very informative blog on Creating a WPF project from scratch. I just wanted to share information about Reasons to Learn WPF Online Training. Hope it helps

    ReplyDelete
  2. While creating checks while processing payment QuickBooks Payroll Support Number
    a few that you've an effective record of previous payrolls & tax rates.

    ReplyDelete
  3. Therefore we have designed a especially dedicated team of certified professionals at QuickBooks Customer Support Number that are able to understanding your issues and errors in minimum time as well as in essentially the most convenient way.

    ReplyDelete
  4. With the aid of Quickbooks Payroll Customer Support Number, you can easily create employee payment on time. In any case, you are facing some problem when making use of QuickBooks payroll such as issue during installation, data integration error, direct deposit issue, file taxes, and paychecks errors, installation or up-gradation or perhaps about just about any than you don’t panic, we provide quality Quickbooks Support.

    ReplyDelete
  5. Moreover, our QuickBooks Enterprise Tech Support Team also handle just about any technical & functional issue faced during installation of drivers for QB Enterprise; troubleshoot any type of glitch that will arise in this version or even the multi-user one.

    ReplyDelete
  6. After after the above troubleshooting steps, it is possible to fix printer problem in QuickBooks. However, if you are facing any trouble or otherwise not in a position to perform the troubleshooting steps on the own, avail our QuickBooks Tech Support Number available round the clock to solve any QuickBooks related issues instantly.

    ReplyDelete
  7. QuickBook Customer Support Number Premier is an accounting software which includes helped you increase your business smoothly. It includes some luring features which can make this software most desirable. In spite of most of the well-known QuickBooks Premier features you might find difficulty at some steps.

    ReplyDelete
  8. you will discover solution every single issue that bothers your projects and creates hindrance in running your QuickBooks Support Phone Number smoothly.

    ReplyDelete
  9. For many of the business organizations, it is and has always been a challenging task to manage the business accounts in a proper way by finding the appropriate solutions. The right solutions are imperative for the growth of the business. Therefore, QuickBooks is available for users across the world as the best tool to offer creative and innovative features for business account management to small and medium-sized business organizations. If you’re encountering any kind of QuickBooks’ related problem, you can get all that problems solved just by using the Quickbooks Support Phone Number.

    ReplyDelete
  10. We possess the best plus the most convenient way to increase your productivity by solving every issue you face with the software. Call us at QuickBooks Support Phone Number to avail the greatest customer care services made for you.

    ReplyDelete
  11. Creating a set-up checklist for payment in both desktop & online versions is a vital task that should be proven to every QuickBooks Payroll Support 2019 user. Hope, you liked your site.

    ReplyDelete
  12. Creating a set-up checklist for payment in both desktop & online versions is an essential task which should be shown to every QuickBooks user. Hope, you liked your site. If any method or technology you can not understand, if so your better choice is which will make call us at our QuickBooks Payroll Support Phone Number.

    ReplyDelete
  13. While creating checks while processing payment in QuickBooks Payroll Support Numberonline, a few that you've an effective record of previous payrolls & tax rates. That is required since it isn’t a facile task to create adjustments in qbo in comparison to the desktop version.

    ReplyDelete
  14. QuickBooks Enterprise Support Phone number provides end-to end business accounting experience. With feature packed tools and features, this software program is effective at managing custom reporting, inventory, business reports etc.

    ReplyDelete
  15. It is possible to stick to the above mentioned steps carefully to get rid of this login issue. However, this is the wisest choice to call at 247 toll-free quantity of QuickBooks to get in touch with one of our technical experts at QuickBooks Tech Support Phone Number for a fast resolution of every issues in QBO.

    ReplyDelete
  16. QuickBooks is the biggest selling desktop and online software across the globe. The software has transformed and helped small & medium sized companies in many ways and managed their business successfully. The smart accounting software is richly featured with productive functionalities that save time and accuracy of the work. As it is accounting software, from time to time you may have a query and will seek assistance. This is the reason why QuickBooks has opened toll free Quickbooks Support.

    ReplyDelete
  17. QuickBooks software is developed in such a way that it will supply you with the best account management experience of this era. However, you may possibly face the difficulty together with your QuickBooks software and start trying to find the answer. Need not worries, if you're facing trouble along with your software you might be just a call away to your solution. Reach us at QuickBooks Customer Service contact number at and experience our efficient technical support of most your software related issues. If you are aa QuickBooks enterprise user, you can easily reach us out immediately at our QuickBooks Support.

    ReplyDelete
  18. You are able to contact us at QuickBooks Enterprise Technical Support , just in case you ever face any difficulty while using this software.

    ReplyDelete
  19. Though these features be seemingly extremely useful as well as in fact these are typically so, QuickBooks Support Phone Number yet there are lots of loopholes that will trigger a couple of errors.

    ReplyDelete
  20. It's likely you have a whole information what the problem your package is facing.
    QuickBooks Support Phone Number client Service A small grouping of execs can handle you manually as a result of they’re absolute to offer the standard services.

    ReplyDelete
  21. Using this edition customers will surely able to check the reports of their invoices and also they can check the schedule of payment. A/A certification of the payment is also available QuickBooks Support USA for every customer when they use this edition of QuickBooks.

    ReplyDelete
  22. Our Professionals have designed services in a competent means in order that they will offer the mandatory methods to the shoppers. we now have a tendency to at QuickBooks client Service are accessible 24*7 you just need certainly to call our QuickBooks Support toll-free number which can be found available on the market on our website. Unneeded to state, QuickBooks Support Phone Number to entrepreneurs in decreasing the price otherwise we’ve seen earlier, however, an accountant wont to help keep completely different accounting record files. Utilising the assistance of QuickBooks, users will maintain records like examining, recording and reviewing the complicated accounting procedures.

    ReplyDelete
  23. If this doesn’t help you, go ahead and connect to us at QuickBooks Toll Free Phone Number. Most of us works 24*7 and serve its customers with excellent service each time they contact us. Regardless of what issue is and however complex it really is, we assure you that we offers you optimal solution as soon as possible.

    ReplyDelete
  24. If you need the help or even the information about it, our company has arrived now to do business with you with complete guidance combined with demo. Connect to us anytime anywhere. Only just contact us at QuickBooks Payroll Support Phone Number . Our experts professional have provided a lot of the required and resolve all type of issues related to payroll.

    ReplyDelete
  25. QuickBooks Enterprise software error free, contact us at an get related to us in minutes. before calling us, all you have to do is always to make sure that you have a QuickBooks Support connection and you're clearly competent to here us clearly before calling us

    ReplyDelete
  26. A group of QuickBooks Tech Support dedicated professionals is invariably accessible to suit your needs so as to arranged all of your problems in an attempt that you’ll be able to do your projects while not hampering the productivity.

    ReplyDelete
  27. HP print head errors are common amongst the HP Printer device. These HP Printer error messages arise for the user to inform them about the HP Printer Tech Support Team Number trouble the device is facing, Thus, if the user still faces this issue, then the only solution is to replace the print head device.

    ReplyDelete
  28. Any QuickBooks user faces any sort of identified errors in their daily accounting routine; these errors can vary from 1 another to a large degree, so our dedicated QuickBooks Payroll Support Phone Number are very well designed with their tools and expertise to offer best possible resolutions very quickly to your customers.

    ReplyDelete
  29. You can use QuickBooks Payroll Support Number to come up with any selection of reports you wish, keeping entries for several sales, banking transactions and plenty of additional. QuickBooks provides a myriad of options and support services for an equivalent.

    ReplyDelete
  30. How to contact QuickBooks Payroll support?
    Different styles of queries or QuickBooks related issue, then you're way in the right direction. You simply give single ring at our toll-free intuit QuickBooks Payroll Helpline Number . we are going to help you right solution according to your issue. We work on the internet and can get rid of the technical problems via remote access not only is it soon seeing that problem occurs we shall fix the same.

    ReplyDelete
  31. Our Experts are available 24*7 to fix your issue. Contact QuickBooks Support Number team to have instant solution.

    ReplyDelete
  32. QuickBooks Customer Support Number, QuickBooks PS series square measure many of the foremost common and therefore the most dangerous errors that our Users need certainly to face. therein case, they ought to forthwith dial the fee QuickBooks tech support team Service.

    ReplyDelete
  33. So, you truly needs to be wondering how are you going to get support through the QuickBooks Payroll Support Number experts? The solution is straightforward.

    ReplyDelete
  34. If this doesn’t help you, go ahead and connect to us at QuickBooks Tech Support Phone Number. Most of us works 24*7 and serve its customers with excellent service each time they contact us. Regardless of what issue is and however complex it really is, we assure you that we offers you optimal solution as soon as possible.

    ReplyDelete
  35. Contact our Technical Team with QuickBooks Support Phone Number: Nowadays it is a big challenge for business organizations to obtain a good means to fix manage their business accounts in a convenient way. To make use of a fruitful organization, you ought to have a robust account management process to grow and lead.

    ReplyDelete
  36. Call QuickBooks Payroll Support to obtain assistance for a couple of your QB payroll related problems. Our technical experts will always there to get the back for anything you necessary for. What you need to do, just dial our toll-free QuickBooks Payroll support number .

    ReplyDelete
  37. In result they get corrupted easily and hamper your workflow easily. It is an easy task to totally avoid this hindrance by just QuickBooks Enterprise Support Number making a wise choice.

    ReplyDelete
  38. QuickBooks has availed many further versions with this specific software namely QuickBooks Pro, QuickBooks Premier, QuickBooks Enterprise, QuickBooks Point of Sale, QuickBooks Payroll, QuickBooks Accountant, QuickBooks Mac and QuickBooks Windows & we fix all QuickBooks Support Number tech issues.

    ReplyDelete
  39. Now you can get a quantity of benefits with QuickBooks Support Phone Number. Proper analyses are done first. The experts find right out of the nature pertaining to trouble. You're going to get a whole knowledge as well. The support specialist will identify the difficulty.

    ReplyDelete
  40. QuickBooks Support contact number has a lot to offer to its customers so that you can manage every trouble that obstructs your projects. There are tons many errors in QuickBooks Support Number such as difficulty in installing this software,

    ReplyDelete
  41. If you’re looking for small-business accounting solutions, first thing experts and happy costumers will recommend you is QuickBooks by Intuit Inc. Intuit’s products for construction contractors are the Quickbooks Pro, Simple Start Plus Pack, Quickbooks Premier Contractor, and Quickbooks Enterprise Solutions: QuickBooks Support Phone Number.

    ReplyDelete
  42. This error may occur due to a problem with the software or hardware components of your desktop PC or any other device that you use for that matter. It will be somewhat a little difficult for you or your accountants to identify as to what problem has occurred and why the tool is not working properly. In such a situation, users may find themselves in trouble. You can get help from our toll-free QuickBooks Enterprise Support Phone Number at any time anywhere.

    ReplyDelete
  43. QuickBooks Premier Support Phone Number is QuickBooks's best toll-free number, there are 3 total methods for getting in contact with them. The second easiest way to talk to their customer support team, according to other QuickBooks customers, is through telling GetHuman regarding the issue above and letting us find somebody to help you. Besides calling, the next favorite option for customers looking for help is via Online Help for Customer Service.

    ReplyDelete
  44. We provide time-saving solutions for you personally Our Support team for QuickBooks Tech Support Number provides you incredible assistance in the shape of amazing solutions. The grade of our services is justified because of this following reasons.

    ReplyDelete
  45. The toll-free QuickBooks Support Phone Number can be reached 24/7 for connecting with all the executives that are trained to assist you to fix any type of QuickBooks related issues. The support executives may even provide remote assistance under servers that are highly secured and diagnose the problem within a few minutes of the time period.

    ReplyDelete
  46. QuickBooks Desktop Support Phone Number could be contacted to learn the ways to generate an automatic backup to save all of your employee-related data from getting bugged or lost at any circumstances.

    ReplyDelete
  47. This error may occur due to a problem with the software or hardware components of your desktop PC or any other device that you use for that matter. It will be somewhat a little difficult for you or your accountants to identify as to what problem has occurred and why the tool is not working properly. In such a situation, users may find themselves in trouble. You can get help from our toll-free QuickBooks Enterprise support number at any time anywhere. If you are facing any errors in QuickBooks, you can contact our QuickBooks error support team to resolve all these error codes at toll-free QuickBooks Enterprise Support Number.

    ReplyDelete
  48. QuickBooks is an item that is progressed while the primary gadget to aid business proficiency and motorize the assignments which are dull in the wild. Regardless, QuickBooks has a considerable number of happy customers in just about every specialty and corner around the globe. just through a call on the customer care or even the toll-free QuickBooks Tech Support Phone Number.

    ReplyDelete

  49. QuickBooks Support Number support also extends to those errors when QB Premier is infected by a virus or a spyware. We also handle almost any technical & functional issue faced during installation of drivers for QuickBooks Premier Version. We also troubleshoot almost any error that will be encountered in this version or this version in a multi-user mode.

    ReplyDelete
  50. To get support from experts, use our QuickBooks Helpline Number +1-855-236-7529. QuickBooks is a business solution that is capable of performing functions like payroll management, accounting, inventory management, and many more. With all these functions, it comes with a bucket of errors and bugs. QuickBooks is an easy to use interface that helps the small and medium business to perform their accounting task. Or contact at QuickBooks Error 12007
    Read more: https://www.techiesupportnumber.com/quickbooks-error-12007/

    ReplyDelete
  51. It is possible to avail the receipt simply by engaging the camera into the receipts scanner and yes it automatically gets put into the expenses.To allow the aforementioned along with other features, go ahead and reach our QuickBooks Support Phone Number to get instant assistance through the pro-advisors.

    ReplyDelete
  52. QuickBooks Customer Care Telephone Number: Readily Available For every QuickBooks Version.Consist of a beautiful bunch of accounting versions, viz.,QuickBooks Pro, QuickBooks Premier, QuickBooks Enterprise, QuickBooks POS, QuickBooks Mac, QuickBooks Windows, and QuickBooks Payroll, QuickBooks has grown to become a dependable accounting software that one may tailor depending on your industry prerequisite. As well as it, our QuickBooks Support will bring in dedicated and diligent back-end helps for you for in case you find any inconveniences in operating any of these versions.

    ReplyDelete

  53. QuickBooks Error 6000 832? What is it & How it occurs?! Call Quickbooks tech support number 1-888-238-7409 for resolution. Visit us:- https://www.enetquickbookenterprise.com/quickbooks-error-6000-832/

    ReplyDelete
  54. Lost connection to your Data file or Can’t able to locate the Data File? No matter, how complex the issues would be. Get instant & easy solutions for your queries by contacting us, on Quickbooks Helpline Number 800-986-4607. We provide the best support service to the Quickbooks user.

    ReplyDelete
  55. Thanks for writing such an informative. We are a team of Certified QuickBooks ProAdvisor that possesses a considerable experience having worked as QuickBooks Consultants over a period of time. Our service offerings comprise Quickbooks Mac support, QuickBooks Online Support, QuickBooks Error Support, Payroll, and anything that is remotely associated with business accounting management. Reach out to us today to find the most affordable business accounting solutions, along with a user-friendly QuickBooks tech support that operates 24/7.

    ReplyDelete
  56. Hi! Excellent post. I couldn’t leave your website without informing you that I liked your blog. I have been using QuickBooks software for the last four months. It is a comprehensive accounting software, and I highly recommend others to give it a shot. To get support for QuickBooks errors, reach our talented experts via QuickBooks Customer Support Phone Number +1-855-907-0605.

    ReplyDelete
  57. QuickBooks Error 9999 happens when QuickBooks fails or crashes whilst it is running, hence its name. It does not necessarily mean that the code was corrupt in some way, but just that it would not work during its run-time.

    ReplyDelete
  58. QuickBooks users might face technical issues but they can resolve them shortly, with the help of brilliant executives. They can report all queries and problems to customer care executives. The squad would provide meaningful solutions to its users at QuickBooks Support Phone Number +1-844-232-O2O2.read more:-https://tinyurl.com/y42ywocq
    & visi us:-https://jamessmithsu.wixsite.com/quickbookssupport

    ReplyDelete
  59. Got stuck in between while estimating Payroll? Don’t fret, Call QuickBooks Customer Service Number 833-780-0086. Our experts at QuickBooks Payroll support offer reliable assistance to the users. For More Visit: http://bit.ly/2V6Sgk7

    ReplyDelete

  60. Well explained and knowledgeable blog click here for QuickBooks support phone number for more detail dial on our QuickBooks Support phone number 844-908-0801

    ReplyDelete
  61. Are you surrounded by errors and unable to send Binance from the Binance account? If you are not perfect at Binance trading and need guidance to execute accurate Binance trading process, you can always have conversation with the elite professionals who are there to handle all your issues. You can always call on Binance Helpdesk Number which is always active and the team is ready to guide you at every step. You can connect with the team executives who are ready to help at every step and fix all queries in between. Binance Customer Service

    ReplyDelete
  62. Are you getting involved in errors while creating the Cash App exchange? In order to create Cash App exchange, you need to have required information and fill in for continue. In case, you get into any trouble during the process, you can always take help from the team of elite professionals who are there to guide you. You can always call on Cash App helpdesk number which is always functional and the team is ready to guide you at every step for better results. Reach them anytime and get quality solutions from the professionals immediately. Cash App Support Number

    ReplyDelete
  63. Are you getting involved in errors while creating the Cash App exchange? In order to create Cash App exchange, you need to have required information and fill in for continue. In case, you get into any trouble during the process, you can always take help from the team of elite professionals who are there to guide you. You can always call on Cash App helpdesk number which is always functional and the team is ready to guide you at every step for better results. Reach them anytime and get quality solutions from the professionals immediately. Cash App Support Number

    ReplyDelete
  64. If you get any technical glitch in the software, get reliable assistance via QuickBooks Customer Service Number Phone Number 1-833-780-0086. It is quite common to observe technical issues in the software, resolve it by giving a call on the QuickBooks Service. For More Visit: https://g.page/quickbookssupporttexas

    ReplyDelete
  65. Gives you the best website address I know there alone you'll find how easy it is. Construction Management

    ReplyDelete
  66. Construction Management Arrowsmith Project Management Limited Site Management Quality Management Project Management Project Management Services
    Construction Management Arrowsmith Project Management Limited Site Management Quality Management Project Management Project Management Services

    ReplyDelete
  67. hanks for providing this great content, very useful Points and Trick

    ReplyDelete
  68. "Exploring WPF Project Creation from the Ground Up: I've stumbled upon an excellent resource that offers an impressive collection of interview questions and answers for both WPF and starting projects from scratch."

    ReplyDelete