In this post we provide the C# source code for a very simple example of a class library. Here is where you can store all of your library routines. Our example only has three objects: a welcome string, a time two method and a times three method. For a client […]

C# Class Library Projects Part 2

When developing C# applications in Visual Studio you can place classes in separate files in your projects. You can also place your classes in completely separate projects. A project that contains only classes (and other type definitions if necessary) but no entry point is called a class library. Class library […]

C# Class Library Projects Part 1

One C# console program can call another C# console program. The calling program can pass in arguments to the called program. The called program can pass back its Exit code and any of its console output. The program being called will not display any console interface. The calling program can […]

C# Calling Another Program In a C# Program

How do you execute a SQL Server stored procedure from within a C# program? The Microsoft Developer Network has some sample code shown below. The application requires permission to access the database and execute the stored procedure. You will need to build a connection string and know the stored procedure […]

C# Execute a Stored Procedure

In XAML, there are several controls that derive from ButtonBase: Button, RepeatButton, ToggleButton, CheckBox and RadioButton. More ButtonBase-derived controls exist, but they were designed to be used inside specific complex controls such as Calendar and DataGrid. ButtonBase contains the Click event.

C# XAML Buttons

The book WPF 4.5 Unleashed by Adam Nathan discusses combo boxes on page 262-267. The ComboBox control enables users to select one item from a list of items while occupying minimal space on the user interface because it displays on the current selection. For a more general discussion of controls […]

C# XAML Combo Boxes

You can use the as operator to perform certain types of conversions between compatible reference types or nullable types. The as operator is like a cast operation. However, if the conversion isn’t possible, as returns null instead of raising an exception. Note that the as operator performs only reference conversions, […]

C# as Operator

The book Illustrated WPF discusses list box controls. A ListBox is a collection of items displayed to the user, from which he or she can select one or more items. As with all ItemsControls, the items in the ListBox can be of any type derived from the UIElement class, including […]

C# XAML List Boxes

Assembly resources are digital objects, such as images, that aren’t generated by the source code. Assembly resources can be embedded in the executable, or you can supply them to the executable as separate files, also called loose files. Assembly resources were briefly discussed in the post C# XAML Resources Introduction. […]

C# XAML Assembly Resources

This is a continuation of Resources Introduction Part 2, where we were discussing XAML Resources from the book Illustrated WPF. Instead of defining the gradient brush in each button, a better strategy would be to define it once as a resource and store it higher up in the element tree—say, […]

C# XAML Resources Introduction Part 3

Code Behind I will illustrate how to use C# code behind to store and retrieve a SolidColorBrush in a StackPanel’s Resources property from the book Illustrated WPF. The XAML code is very simple as shown below. Below that is the code behind. This post is a continuation of Part 1. […]

C# XAML Resources Introduction Part 2

WPF supports two types of resources: binary and logical. Binary resources include, for example, images or icons that are supplied from outside the code. These are also called assembly resources. These are resources in the common sense of the term as it’s been used since the beginning of Windows programming. […]

C# XAML Resources Introduction

Code Behind and Object Names This discussion is based on the book Illustrated WPF by Daniel S on page 86 (Chapter 4). There’s a difference creating class objects with C# and creating them with XAML. Objects created in C# have names. For example, the button created in the following line […]

C# XAML Introduction Part 4 Object Names Part 1

Consider the following C# code that creates a button. The XAML parser or compiler must look for a type converter that knows how to convert the string ‘white’ into the desired data type. Consider the following XAML that creates several buttons. All these buttons are essentially the same. Here is […]

C# XAML Introduction Part 3 Type Converters