-
Book Overview & Buying
-
Table Of Contents
Windows Presentation Foundation 4.5 Cookbook
By :
WPF introduces the concept of logical resources, objects that can be shared (and reused) across some part of a visual tree or an entire application. Logical resources can be anything, from WPF objects such as brushes, geometries, or styles, to other objects defined by the .NET Framework or the developer, such as string, List<>, or some custom typed object. This gives a whole new meaning to the term resources. These objects are typically placed inside a ResourceDictionary and located at runtime using a hierarchical search, as demonstrated in this recipe.
Make sure Visual Studio is up and running.
We'll create a simple application that demonstrates creating and using logical resources:
Create a new WPF Application named CH02.SimpleResources.
Open MainWindow.xaml and replace the Grid element with a StackPanel.
Add a Rectangle element to the StackPanel, as shown in the following code snippet:
<Rectangle Height="100" Stroke="Black">...