Skip to main content

HOW TO HANDLE SIMPLE EVENTS IN WPF APPLICATION.

Starting out as a beginner programmer I always wanted to make a real world application, something different from a command line application. I was just looking for a blog created by someone who keeps things simply stupid, some people think that programming is really easy, but the fact is "programming is a complex
thing you will ever get into as such it should be kept very simple for beginners like us"

I made this post to show you how simple it is to control what a button does when it is clicked, so whether you are a beginner that doesn't know anything about programming, you will be getting the real idea of what happens when a button is clicked on the Graphical User Interface of  your program.

So, for you to get this idea, we are going to be developing a real WPF application that says "Hello Word!" when a button is clicked.
We will be doing this with Visual Studio 2012.

Features of our simple program includes:

  •  speech technology: We will make our program speak the "Hello World" and as well print the text.
  • and will try to make it look good.
  1. Start a new Visual studio project and name it TalkingButton.
  2. After the the project designer loads, resize the MainWindow so that the width becomes 525 and the Height 90.
  3. Drag a button from the tool window on the inner grid of the the MainWindow.
  4. Enter talkButton as the name and Talk as the Content.
  5. Add a textbox on the space that remains on the grid. and name it textView.
  6. Position the button so that it looks like this:
  7. Change the background color of the textbox to black and the foreground to any color you want.
  8. double click the button and program what the button does, in this case the button will force the textblock to print hello world on the screen. So our code will look like this:
private void talkingButton_click(object sender, RoutedEventArgs e) { textView.Text="Hello World"; }

Now lets add Speech Technology.
Right click  Add Reference in solution explorer,
look for System.Speech,
check the box next to it and click ok.
Add the following using Statement

using System.Speech.Synthesis;

Add this before the the constructor:
SpeechSynthesizer ss=new SpeechSynthesizer();

and this inside the event method of the talkingButton:
ss.SpeakAsync("Hello World");

Run your program and click the talking button. notice what happens when you clicked the button.
This is what we call event handling, there are other complex event you can handle, I suggest you play around with something.

Please ask your questions in the comment section along side your criticism.
Thanks for reading.


Comments

Popular posts from this blog

Microsoft will allow you to upgrade your pirated Windows 7 or 8 to full Windows 10 for little or no amount.

Microsoft's latest Operating System has been trending for a while now, while some are still contemplating on who gets a free upgrade from the two previous Microsoft's Operating Systems just like the company promised and who wouldn't, Microsoft has announced that the upgrade to Windows 10 would be free for genuine Windows 7 or 8 users and there is a good news for pirated Windows 7 or 8 users, they too might go to the Promised Land for free or pay a little fee.Hmmm..., with this in place, you can see how determined Microsoft is to pull everyone into its Windows 10 ecosystem. You know, when Windows 10 Technical Preview was first announced along with how it's going to operate (Windows as a Service), I thought Microsoft is finally kicking Windows Pirates out of business, but it seems Microsoft is giving them one more chance to own a genuine Windows, maybe Windows 10  is going to be "un-piratable" (let's just hope MS gets it right).Hahaha!...., before I forget,

HOW TO WRITE, COMPILE AND RUN C++ CODE ON LINUX KALI

This article is for hackers who want to develop a c++ program on Kali Linux without having to install any additional software. While some would tell you that you need to install an additional software or a compiler in order to develop a simple program in c++ on Kali Linux, I am going to show you how to develop a c++ program on this distro right out of box. Your Linux Kali comes pre-installed with a c++ compiler called g++ so we are going to write a C++ hello word code and compile it with this compiler. Before we get started, first open up terminal and run to verify if this compiler is installed on you machine: g++ -v if the compiler is pre-installed, you should get the version information of the compiler, otherwise, you should get an error. Now let's jump right in. In your terminal window, type in: nano MyCpp.cpp to create a c++ file and lunch it in nano editor for editing. When nano opens, type in the following c++ code and press Ctrl+x then y and then R

LOAN MANAGEMENT SYSTEM (My Project Idea)

There are many companies that specializes on giving loan to people; they make their profits by collecting interest on any money they lend out, and before a loan can be given to any customer, the customer must provide a collateral and some details such as:  contact details and a reference/guarantor. When the loan is finally given to the customer, they charge interest based on the the amount given to the customer for a given period of time which could be daily, weekly, monthly or yearly.  For example, a company could be collecting interest based on a particular amount for a given period of time like: $200,000 loan would have an interest tag of $2,000  per month until the money is returned, and $100,000 would have an interest of $1,000 per month until the money is returned.  In  addition, the customers need to know when the time for them to pay their interest comes e.g.  at the end of the month or the timing model with which the calculation is being made. Usually, these companies sends ou