Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
WPF Resources Guide: Learn How to Use Resources in XAML
1.
2.
3. A resource is an object that can be reused in
different places in your application.
Resources allow you to define object for use in
you application and share object among
elements
Any object in WPF can be a resource
WPF use ResourceDictionary class to manage
resources and FrameworkElement base class to
work with resources
ResourceDictionary like a Hashtable (key/object)
4. System scope
Configure at a system-wide
level
Example: brushes, fonts, and
metrics…
Application scope
Used throughout your
application
Useful for styles or control
templates
Windows scope
Used throughout windows
Element scope
Used internal the element
5. Designing Settings
Preferred settings mechanism by ApplicationSettingsBase class
from the System.Configuration namespace
Designer support
Two type: User/Application settings
Using settings
Load: Properties.Settings.Default.[Your setting]
Save: Properties.Settings.Default.Save();
Integrating withWPF databinding
<TextBlock
Text="{Binding
Path=MyAppSettings,
Source={x:Static local:Properties.Settings.Default}}" />
At the heart of resource management is the ResourceDictionary class. Outwardly,
this is just a simple collection class. It behaves much like an ordinary Hashtable—it
allows objects to be associated with keys, and it provides an indexer that lets you
retrieve those objects using these keys. So, in theory, you could use the
ResourceDictionary like a Hashtable
For example, the
FrameworkElement base class, from which most user interface elements derive, provides
a resource dictionary in its Resources property