WPF Resources
The logical resource (also known as an object resource) system is a way to name and refer to commonly used objects within a WPF application. While logical resources are often authored in XAML, they can also be defined in procedural code.
WPF supports two flavors of resources. The first is a binary resource,and this category typically includes items most programmers consider a resource in the traditional sense (embedded image files or sound clips, icons used by the application, and so on).
The second flavor, termed object resources or logical resources, represents a named .NET object that can be packaged and reused throughout the application. While any .NET object can be packaged as an object resource, logical resources are particularly helpful when working with graphical data of any sort, given that you can define commonly used graphic primitives (brushes, pens, animations, etc.) and refer to them when required.
How to allocate resources are
Essentially, the {DynamicResource} markup extension is able to detect whether the underlying keyed object has been replaced with a new object. As you might guess, this requires some extra runtime infrastructure, so you should typically stick to using {StaticResource}unless you know you have an object resource that will be swapped with a different object at runtime, and you want all items using that resource to be informed.
WPF supports two flavors of resources. The first is a binary resource,and this category typically includes items most programmers consider a resource in the traditional sense (embedded image files or sound clips, icons used by the application, and so on).
The second flavor, termed object resources or logical resources, represents a named .NET object that can be packaged and reused throughout the application. While any .NET object can be packaged as an object resource, logical resources are particularly helpful when working with graphical data of any sort, given that you can define commonly used graphic primitives (brushes, pens, animations, etc.) and refer to them when required.
How to allocate resources are
- Window-Wide Resources : in each xalm file.
- Application-Level Resources : in App.xaml file.
- Merged Resource Dictionaries : in the Resource Dictionary xaml file.
- A Resource-Only Assembly : in Resource Dictionary xaml file within separated assembly.
Essentially, the {DynamicResource} markup extension is able to detect whether the underlying keyed object has been replaced with a new object. As you might guess, this requires some extra runtime infrastructure, so you should typically stick to using {StaticResource}unless you know you have an object resource that will be swapped with a different object at runtime, and you want all items using that resource to be informed.
댓글
댓글 쓰기