XAML Markup Extensions
The aim of this project is to improve the capabilities of XAML code
while keeping an eye on a
good XAML code readability
. This covers the developement of useful XAML markup extensions for Silverlight (SL) and the Windows Presentation Framework (WPF) as well as helper classes to extend their scope of operation.
This project is and will be free for everyone to use. This also implies that any contribution to it is welcome. Thus, feel free to create your own fork on GitHub (refer to links section below).
The library now partially supports design time for Silverlight!
Improved markup extension nesting
This project offers a straightforward solution to the problem that you don't know where you are in case of a nested markup, giving you the advantage to
exactly control the output of your markup extension depending on the nesting tree
, thus extremely expanding their application range. It's very easy to implement, even if you never built markup extensions before.
Take a look at this sample (coming soon) for a demonstration.
- Each markup extension knows its nesting subtree (downto each dependency object)
- During runtime and designtime
- Multiple branches possible
- Markup extension (trees) can be declared as resources to reduce memory and calculation overhead
- ProvideValue is replaced by a function delivering the particular endpoint information
- Notification engine to update the whole nesting tree if needed
- Support of List objects
- Interface for existing markup extensions included
Markup extensions are not able to resolve their target dependency object when nested into each other. This restricts their usage to a small application range, because useful information such as the types of the target object and property as well as the content
of additional attached or inherited properties could not be read out in order to adopt the own result to the particular situation.
Therefore, a new markup extension base class derived from the WPF MarkupExtension class was developed. In this class, the whole nesting tree is properly tracked during the ProvideValue function that is called by the XAML parser at designtime or runtime. This
enables each markup extension in the tree to adopt its output to each endpoint (the target dependency object) of its subtree including multiple branches caused by markup extensions referenced as a resource.
With the help of the nesting feature, the
WPF Localization Extension
was enhanced. Please refer to the homepage and the latest GitHub commits of this project for further information.
- Concatenate extension
- Concatenate a list of strings (or markup extensions delivering these strings)
- Provide a format code to control the output
- Alternating grid color extension
- Apply an alternating color to rows of a grid.
- Dynamic binding extension - allows changes of Source and Path
- Aspect ratio extension - bind width and height of a control while keeping a particular aspect ratio
Where can I get it?
View up-to-date source at GitHub:
A NuGet package is also available:
- WPF .NET 3.5
- WPF .NET 4.x
- SL 5.0