Book Image

Windows Presentation Foundation Development Cookbook

Book Image

Windows Presentation Foundation Development Cookbook

Overview of this book

Windows Presentation Foundation (WPF) is Microsoft's development tool for building rich Windows client user experiences that incorporate UIs, media, and documents. With the updates in .NET 4.7, Visual Studio 2017, C# 7, and .NET Standard 2.0, WPF has taken giant strides and is now easier than ever for developers to use. If you want to get an in-depth view of WPF mechanics and capabilities, then this book is for you. The book begins by teaching you about the fundamentals of WPF and then quickly shows you the standard controls and the layout options. It teaches you about data bindings and how to utilize resources and the MVVM pattern to maintain a clean and reusable structure in your code. After this, you will explore the animation capabilities of WPF and see how they integrate with other mechanisms. Towards the end of the book, you will learn about WCF services and explore WPF's support for debugging and asynchronous operations. By the end of the book, you will have a deep understanding of WPF and will know how to build resilient applications.
Table of Contents (13 chapters)
2
Using WPF Standard Controls

How to do it...

Follow these steps to edit the progress bar template:

  1. Open the MainWindow.xaml file and replace the default Grid control with a vertical StackPanel.
  2. Add two ProgressBar controls inside the StackPanel and set their Height, Width, and Value properties, as shared here:
<StackPanel Orientation="Vertical"> 
    <ProgressBar Height="30" 
                 Margin="10" 
                 Value="40"/> 
    <ProgressBar Height="30" 
                 Margin="10" 
                 Value="60"/> 
</StackPanel>
  1. If you run the application, you will see the application window contains two progress bar controls. Both the controls will have the default style applied to them. Here's a screenshot of the same:
  1. Now, we will create a custom template for the ProgressBar control and apply it to the second progress bar. To do this, add the following markup inside the Window tag to define the template...