Understanding WPF Namespaces

Here we will look at how Windows Presentation Foundation (WPF) uses Namespaces. Let’s start a new WPF project: We can see here there are XML namespaces defined: xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″ xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″ WPF uses XML Namespaces, as defined by the W3C. Namespaces are used to prevent conflicts from occurring, to distinguish code from developers. To solve problems where two developers may use the same elements in their code, namespaces and prefixes … Continue reading Understanding WPF Namespaces

WPF XAML Hello World

Here is a simple example to get started with Windows Presentation Foundation (WPF) and Extensible Markup Language (XAML). First, create a new Visual Studio project and select under Windows templates “WPF Application”: You should see something like this in Visual Studio: You will see a default window. Next, let’s add a button to the window. Open Toolbox and drag a Button across. Then, give the button a name: Double click the … Continue reading WPF XAML Hello World

WPF – Grid Splitter

Let’s say we have the following WPF form that has 3 rows and 2 columns: If we wanted to give the user the ability to resize the columns, we can use a GridSplitter. Under WPF Controls, you will see GridSplitter: First, we will add an additional colum. This will hold the splitter: Next, we will move our textboxes to the right column, so it frees the middle column for resizing: … Continue reading WPF – Grid Splitter

WPF – Column and Row Definitions

In a WPF grid, we can define columns and rows. To do this, create a new WPF app in Visual Studio: You will see below: Select Layout in Properties. You will see Column Definitions and Row Definitions: Select Column Definitions. Click Add: Here you can add a column definition, which is defining a column, just as you would in a table for example: Add a second column definition: You will … Continue reading WPF – Column and Row Definitions

WPF – Disable Visual Studio UI Debugging

When you create WPF apps in Visual Studio, you will see an extra toolbar on your WPF forms: This is the UI Debugging Tools for XAML in Visual Studio. Options include: Go to Live Visual Tree Enable Selection Display Layout Adorners Track Focused Element To disable this, in Visual Studio select Tools->Options: Debugging->General->Enable UI Debugging Tools for XAML: Rerun and you will now not see the tools: