Switch On The Code RSS Button - Click to Subscribe
Oct
2

WPF Tutorial - Getting the DoubleClick Event

In WinForms, everything that derived from System.Windows.Forms.Control had the MouseDoubleClick event - and not suprisingly, in WPF, everything derived from System.Windows.Controls.Control also has a MouseDoubleClick event. But there is a key difference - in WinForms, almost everything that gets displayed on the screen is derived from System.Windows.Forms.Control in some way - while in WPF, there are a number of items you can put on the screen that do not actually derive from System.Windows.Controls.Control. So today we are going to take a look at how to get double clicks when you are not derived from System.Windows.Controls.Control.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | No Comments »

Sep
25

WPF Tutorial - Using The Built-In Commands

One of the features that WPF has is actually a blast from the past - something that MFC used to have, but was never included in WinForms. This is the concept of Commands. Commands are somewhat like events in that they are based on actions in the user interface, a command can [...]
 
Read More »

Posted in WPF, XAML, All Tutorials | No Comments »

Sep
16

WPF Tutorial - Using An ItemsPanel

One of the most useful things about WPF is how flexible all of the built in controls are. Don't like how the tabs look on a tab control? Restyle them! Need to have images inside your combo box? Sure, no problem! This flexibility extends deep into a number of controls, and today we are going to take a look at controlling layout in an ItemsControl by setting the ItemsPanel.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | No Comments »

Sep
3

WPF Tutorial - Priority Bindings

Bindings, bindings, bindings. WPF is all about bindings - and you can't be all about bindings unless there are a whole bunch of different types to play with. We have looked at a couple different types here at SOTC before - I won't list them all, it is probably just easier to look at list in the WPF category. Today we are going to introduce yet another type of binding - the Priority Binding.
 
Read More »

Posted in WPF, All Tutorials | 1 Comment »

Aug
21

WPF Tutorial - Using Splash Screens in SP1

Splash screens - everyone loves them, right? Actually, I'm not a big fan of them, but sometimes they are a necessary evil - especially in the world of WPF. A cold start up of a WPF application can be, well, slow - mostly because there are a lot of common WPF dlls that need to be loaded. Once they are loaded for the first time after bootup, WPF apps generally start pretty fast, but that first WPF app after a reboot can crunch away at your hard drive for quite a few seconds.
 
Read More »

Posted in WPF, All Tutorials | 1 Comment »

Jul
22

WPF Snippet Tutorial - Aligning ListView Items

WPF is powerful. So powerful in fact, that sometimes it's hard to find styles and settings to make it do what you want. Aligning ListView items was one such example for me. This snippet tutorial will show you how to use a style to vertically and horizontally align the contents of ListView cells.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | 3 Comments »

Jul
21

WPF Tutorial - Using MultiBindings

If you've touched WPF at all, you've probably realized that bindings are an extremely important piece of the framework. We've talked about WPF bindings a number of times here at Switch On The Code (most recently in a post where we talked about Binding Converters) - and yet we have just barely scratched the surface of the world of bindings. Today, we are going to take a look at MultiBindings.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | No Comments »

Jul
16

WPF Tutorial - How To Use A DataTemplateSelector

DataTemplates are an extremely powerful part of WPF, and by using them, you can abstract all sorts of display code. However, there are times when they fall short - and initially when I was learning WPF I was disappointed by that. For instance, you only get to set one DataTemplate on an items control, and while that made sense, it felt limiting. What if I wanted to use different templates depending on the content of the item? Do I have to build all that logic into a single data template?
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | 1 Comment »

Jul
15

WPF Tutorial - Binding Converters

I'm going to come right out and say it, binding converters are one of the nicest pieces of WPF I've run across so far. Simply put, they provide a translation between your binding source and destination. The most common use I've found is when I'm binding to user interface elements, because on many occasions I don't store something in a data member that can just be stuck on the screen. This tutorial will provide an introduction to what binding converters are and how to use them.
 
Read More »

Posted in WPF, C#, All Tutorials | 1 Comment »

Jun
25

Working With The WPF Dispatcher

Proper use of threads can greatly increase the responsiveness of your WPF applications. Unfortunately, you can't update any UI controls from a thread that doesn't own the control. In .NET 2.0, you used Control.Invoke(). Now, we've got something similar but more powerful - the Dispatcher. This tutorial will explain what the Dispatcher is and how to use it.
 
Read More »

Posted in WPF, C#, All Tutorials | 3 Comments »

Jun
24

WPF Tutorial - Using WPF In WinForms

A little while back, we did a tutorial on how to embed WinFoms controls inside of WPF application (you can read all about it here). Today, we are going to flip that on its head - we are going to take a look at how to embed WPF controls inside of a WinForms application.

 
Read More »

Posted in WPF, C#, All Tutorials | 5 Comments »

May
20

WPF Tutorial - Using WinForms In WPF

So we all know that WPF is awesome, but it is still a very young framework. And so, sometimes, it doesn't have everything that we might want or desire. For instance, there are a number of controls in WinForms that don't exist in WPF - and they come in handy once in a while. What we are going to look at today is how to use WinForms controls inside of WPF - a very easy and almost painless process, in my opinion.
 
Read More »

Posted in WPF, C#, All Tutorials | 1 Comment »

Mar
14

WPF Tutorial - How To Use Custom Cursors

So a while back, I did a tutorial on how to do custom cursors in WinForms. In that post I said that at some point in the future, I would write a post on how to do custom cursors in WPF - and here we are! A lot of the code used today is based off of the code from that previous tutorial, so if you haven't read it, I would go do so before you continue.
 
Read More »

Posted in WPF, C#, All Tutorials | 1 Comment »

Mar
7

WPF Tutorial - Introduction To Dependency Properties

So I was going to dive right in and do a part 2 on the WPF ListView tutorial from last week, but as I was writing the code I realized that a lot of it relies on some new and very different constructs that WPF provides to developers. Two of these are deep enough topics on their own that I thought it would be a good idea to give an introduction to them before I dived back into the ListView stuff. So today we are going to talk about Dependency Properties, and in a future tutorial I will talk about how binding works in WPF.
 
Read More »

Posted in WPF, C#, All Tutorials | 5 Comments »

Feb
28

WPF Tutorial - Using The ListView, Part 1

Many of the controls in WPF have a downright dizzying array of capabilities and features, due in large part to the composibility of all the components. The ListView control is a great example of this - the possibilities are almost endless. This series of tutorials on the ListView will hopefully make the space of possible options seem not quite as daunting.
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | 8 Comments »

Feb
18

WPF Tutorial - Creating A Custom Panel Control

The world of WPF gives you an extreme amount of flexibility right off the bat - with things like styles, control templates, and the composability of almost anything, at first it seems like everything is right there at your fingertips. And while there is a lot immediately accessible, there are still cases where you have to get down into the nitty-gritty. Today we are going to take a look at how to create a WPF custom control - more specifically, a custom panel.The available panels in WPF are great (perhaps we will have a tutorial on how to use them all at some point in the future). But maybe you have a very specific need, and none of the panels quite work the way you want?
 
Read More »

Posted in WPF, XAML, C#, All Tutorials | 7 Comments »

Jan
18

The WPF Tab Control - Inside and Out

When it comes to the WinForm's Tab Control, there was a lot left to be desired. If you had to make major design changes, you were better off just writing one from scratch. The WPF Tab Control makes major strides in the right direction. This tutorial is going to introduce you to the tab control and demonstrate how to re-skin it look like how you want.
 
Read More »

Posted in WPF, XAML, All Tutorials | 25 Comments »

Jan
9

Creating Custom Shapes with XAML

I don't know if you've ever had to draw your own shapes before WPF, but if not, I can tell you it used to be a lot harder. You don't have to override the OnPaint function or listen for the Paint event anymore. You simply create a shape as if it were any other object and position it where you want it. WPF takes care of everything else.
 
Read More »

Posted in WPF, XAML, All Tutorials | 6 Comments »