Sunday, July 9, 2017

WPF with XAML and C# - Controls

Basic controls in WPF

  1.  Text Controls
  2.  Selection Controls
  3.  List Controls
  4.  Other Controls

Simple form sample with set of basic controls

section 1 of form application

section 2 of form application


section 3 of form application


section 4 of form application


Once combined above all sections together as one xaml file, it will be a wpf simple form application with set of controls.  Design view of the given application as below;


Let's discuss on Events basics with samples in next part of this series. 

WPF with XAML and C# - Layout and Panels

There are set of main layout and panels in wpf

  1. Grid
  2. Stack Panel
  3. Wrap Panel
  4. Dock Panel
  5. Canvas
Grid rows and columns 
A Grid Panel provides a flexible area which consists of rows and columns. In a Grid, child elements can be arranged in tabular form.


Design view:



Stack Panel
In stack panel, child elements can be arranged in a single line, either horizontally or vertically, based on the orientation property. It is often used whenever any kind of list is to be created.


Design View: 


Wrap Panel
Child elements are positioned in sequential order, from left to right or from top to bottom based on the orientation property. Auto Wrapping items on wrap panel when it is resizing the view.


Design View:


Dock Panel
A Dock Panel is used to dock child elements in the left, right, top, and bottom positions of the relative elements.

Design View:


Canvas
Child elements can be positioned explicitly using coordinates that are relative to the Canvas any side such as left, right, top and bottom.


Design View:


 
     Try all yourself and enjoy it . See you in next part of series.

 ( Introduction - Part 1)                                                                 (Controls - Part 3)

WPF with XAML and C# - Introduction

WPF - Windows Presentation Foundation
XAML - Extensible Application Markup Language

 WPF is used in development of windows application and also enterprise application with c#. You can be used visual studio to build wpf application.  Xaml is also used with the development of wpf application.  XAML is the language behind the visual presentation of an application that you develop in Microsoft Expression Blend, just as HTML is the language behind the visual presentation of a Web page. (What is XAML?)


 Starting with Hello world application


  1. Open Visual studio -> File -> New -> Project -> Under visual c# -> you can select WPF Application and give project name as "HelloWPF" or any name as you want.  
  2. Then it will be created two main files. one is with .xaml extension (MainWindow.xaml) and other one is with  .xaml.cs extention (MainWindow.xaml.cs)
  3. You can easily edit your xaml file with provided toolbox and properties in vs or manually editing it as appropriate way.
  4. Below is the sample screen shot of xaml file.

    This is the xaml file of Hello world wpf application


  5. Now you can run the application.  See you in next part of this series.
(Layout and Panels - Part 2)