Let me first explain what is WPF?
WPF is the graphical subsystem if the .NET 3.0 framework and it is there to take the place of window forms which we used with earlier versions of .NET
So what’s so great about WPF?
Actually WPF is has its roots in DirectX API so you can easily create 2D and 3D interfaces in it without putting ant load on the processor. Also it is vector based and stores the information for the generating the UI in separate XAML files. So we have logical separation of a control from its appearance.
Further details: http://en.wikipedia.org/wiki/Windows_Presentation_Foundation
The following are the requirements for running this example:
- rubyclr gem. Use gem install rubyclr -y
- .NET framework 3.0
In this example I will creating a creating a textarea along with a button, trapping the events on the button and logging it inside the textarea .
Here is the code for the xaml file. Store this file with filename ui.xaml. This file contains the UI for the application.
Next I will be creating the codebehind file in ruby. Here in this file we have all the application logic. Save this file as logic.rb.
The code given above explains itself.
We are first loading the ui.xaml file and then finding the two controls in the lines 8, 9.
Then the three event handlers are declared in lines 11, 14, 19. So whenever the mouse events are fired the corresponding event if traced into the textbox.