XAML Basics Tutorial WPF











>> YOUR LINK HERE: ___ http://youtube.com/watch?v=Z0a0QYNlKig

Learn the basics of XAML: the difference between StackPanel and Grid, how to define columns and rows, a few controls (button, textblock, textbox, combobox, checkbox), relative value (star *), how to make comments, copy, quickly cut and paste lines, select square, hide code blocks, etc. • Subscribe! ► https://www.youtube.com/c/QuasimodoPr... • 0:00 Create a WPF Project • 0:40 Window structure • 1:00 Attributes, values, events • 1:42 Containers • 1:53 Difference from Windows Forms • 2:35 StackPanel vs Grid • 4:09 RowDefinitions • 4:38 Nesting • 5:28 XAML comments • 5:38 Grid • 5:52 Star * • 7:02 Margin • 7:12 Border • 7:22 Padding • 7:32 Padding vs Margin • 8:41 TextBlock • 8:59 Single-line tag • 9:09 Vertical alignment • 9:42 TextBox • 10:01 Enable and Disable Controls • 10:11 TextChanged event • 10:30 Name • 11:00 TextBox: Margin and Padding • 11:36 Read-only textbox • 11:49 Hex Colors • 12:18 CheckBox • 14:49 ComboBox • 16:00 Access controls from code • 16:31 Button Click event • 16:54 Quick UI design demonstration • WPF stands for windows presentation foundation. XAML stands for extensible application markup language. It is quite similar to HTML and XML because you will see angle brackets, tags, attributes and nesting. Even comments are written the same way. After you create your project, by default you have one window created for you. Window consists of two parts: XAML - your interface, and .cs - your code. When you work on your interface you have two halves: design and XAML. Ideally you use design to preview and XAML to make changes. You can have only one top-level element. In our case we have a window. This window has attributes with values. Every element including a window can have events which are triggered in different situations, for example a window has an event called Loaded, which is fired when all visual elements are ready to be displayed. Since this tutorial is about XAML, not C#, we will not code much. So, let's just show a message which says ready . As you see the event fired, and we saw a message. Let's comment this line not to see it every time. Window also can have only one element which must be a container. You will mainly use a StackPanel and a Grid. And sometimes you will use a Border. If you previously used Windows Forms, bad news for you: ideally you type your code and not use a tool box. But don't worry you will get used to it very quickly. Besides you can preview UI changes when you type. You still can use the toolbox just to see what controls actually exist in WPF. If you are interested why you shouldn't use the toolbox then it's because after you drag-and-drop them they will appear in the wrong place in the structure of your window. Moreover, you will get attributes that you don't need. Let's get started by changing attributes. For example, let's change the height on the window. Now let's get back to a StackPanel and a Grid which have different purposes but I must say that I mainly use a StackPanel when I am lazy and a Grid when I try to make something decent. In a StackPanel elements stack one after one. • A StackPanel can have vertical or horizontal orientation. Elements will have an auto size, i.e. size just enough to fit the content. Sometimes I wouldn't recommend using StackPanel at all. For example, if it has horizontal orientation and you add several buttons with different text, each of them will have a different width. If you need something more complex, relative, with columns and rows, you will use a Grid which provides all of that. Unlike StackPanel, Grid occupies everything available. If you define no columns and rows, elements will be placed on top of each other. So, let's define a few columns. • Each column definition stands for one column. • Controls are defined after column definitions. To place an element into a certain column you should set attribute Grid.Column to a zero-based index. • If you want to select a square, just hold the Alt key. • Now let's look at any program to see some rows in it. For example, in notepad we see just three rows. Let us define three rows too instead of columns and change their attributes as well. • Remember I said that HTML and XAML were very alike, specifically I mentioned nesting. Well, you can nest one container inside another and as far as I know nesting has no limits in degree. You can toggle every logical block in XAML by pressing a little button to the left. • If a Grid has multiple rows, you can put another StackPanel or Grid inside a row. • Theoretically we could set an equal width manually for each button but we would need to repeat it every time. • In Grid you can define columns and rows at the same time. • A very useful feature in XAML is a star which means: take all available space. • In other words, all space except for the space, used by other columns, will be given to a star column. • Moreover, you can give a star to multiple columns which will evenly divide the space. • More WPF Basics ►    • WPF Basics  

#############################









Content Report
Youtor.org / YTube video Downloader © 2025

created by www.youtor.org