TOC

This article is currently in the process of being translated into Tamil (~52% done).

Getting started:

Hello, WPF!

எந்தவொரு நிரலாக்க பயிற்சியிலும் முதல் மற்றும் மிகவும் உன்னதமான எடுத்துக்காட்டு "Hello World!" எடுத்துக்காட்டு, ஆனால் இந்த பயிற்சியில் அதற்கு பதிலாக தொடக்கத்தில் அதை நாம் "Hello, WPF!" என்று இந்த உரையைத் திரையில் பெறுவதே குறிக்கோள் மற்றும் இதைதொடங்குவது எவ்வளவு எளிது என்பதைக் காண்போம்.

இந்த டுடோரியலின் மீதமுள்ள நீங்கள் ஒரு IDE நிறுவப்பட்டிருப்பதாகக் கருதுகிறேன், முன்னுரிமை Visual Studio அல்லது Visual Studio Community (அதை எவ்வாறு பெறுவது என்பதற்கான வழிமுறைகளுக்கு முந்தைய கட்டுரையைப் பார்க்கவும்). நீங்கள் வேறொரு தயாரிப்பைப் பயன்படுத்துகிறீர்கள் என்றால், உங்கள் தயாரிப்புக்கான வழிமுறைகளை நீங்கள் மாற்றியமைக்க வேண்டும்.

விஷுவல் ஸ்டுடியோவில், New project மெனுவிலிருந்து File ஐத் தேர்ந்தெடுப்பதன் மூலம் தொடங்கவும். உங்கள் இடதுபுறத்தில், வகைகள் இருக்க வேண்டும். குறியீடு சம்பந்தப்பட்ட போதெல்லாம் இந்த பயிற்சி C# இல் கவனம் செலுத்துகிறது, எனவே நீங்கள் வார்ப்புருக்கள் பட்டியலிலிருந்து அதைத் தேர்ந்தெடுக்க வேண்டும், மேலும் நாங்கள் விண்டோஸ் பயன்பாடுகளை உருவாக்குவோம் என்பதால், நீங்கள் வகைகள் Windows ஐ தேர்ந்தெடுக்க வேண்டும். இது வலப்பக்கத்தில் சாத்தியமான விண்டோஸ் பயன்பாட்டு வகைகளின் பட்டியலை உங்களுக்கு வழங்கும், அங்கு நீங்கள் ஒரு WPF Application ஐ தேர்ந்தெடுக்க வேண்டும். Name உரை புலத்தில் எனது திட்டத்திற்கு "HelloWPF" என்று பெயரிட்டேன். உரையாடலின் கீழ் பகுதியில் உள்ள மீதமுள்ள அமைப்புகள் சரியாக இருப்பதை உறுதிசெய்து, பின்னர் Ok பொத்தானை அழுத்தவும்.

உங்கள் புதிய ப்ராஜக்டில்(Project) பல்வேறு கோப்புகள் (files) இருக்கும், ஆனால் அவற்றில் நாம் ஒன்றை மட்டுமே பார்க்க இருக்கிறோம். MainWindow.xaml. இது தான் நம் பயன்பாடு (அல்லது) செயலி (application) தொடங்கும்பொழுது முதலில் தோன்றும் Window. நாம் இதை பிறகு தேவைக்கேற்ப மாற்றிக்கொள்ளலாம். அதில் XAML நிரல் (Code) இருக்கும். (XAML பற்றி பின்வரும் கட்டுரைகளில் காணலாம்). XAML நிரல் கீழ் உ‌ள்ளது போல தோன்றும்.

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
    <Grid>

    </Grid>
</Window>

This is the base XAML that Visual Studio creates for our window, all parts of it explained in the chapters on XAML and "The Window". You can actually run the application now (select Debug -> Start debugging or press F5) to see the empty window that our application currently consists of, but now it's time to get our message on the screen.

We'll do it by adding a TextBlock control to the Grid panel, with our aforementioned message as the content:

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
    <Grid>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="72">
Hello, WPF!
</TextBlock>
    </Grid>
</Window>

Try running the application now (select Debug -> Start debugging or press F5) and see the beautiful result of your hard work - your first WPF application:

You will notice that we used three different attributes on the TextBlock to get a custom alignment (in the middle of the window), as well the FontSize property to get bigger text. All of these concepts will be treated in later articles.

Congratulations on making it this far. Now go read the rest of the tutorial and soon you will master WPF!