What is XamlQuery?
XamlQuery: The Write Less, Do More, Silverlight Library.
XamlQuery selectors are feature rich and similar to CSS (cascading style sheet) selectors and jQuery selectors. The controls can be found very easily using simple to complex selector queries or managed helper methods. Also, XamlQuery provides a powerful API that simplifies complex operations on found controls. Most of the API functions can be invoked in a single line of code. For example, the following code hides all rectanges in a canvas with animation.
The latest stable release of XamlQuery is version 1.2 and can be downloaded from CodePlex.
- Unlike other markup languages (like HTML) the controls tree structure in the rendered Silverlight output is different from markup declarations (XAML). The controls cannot be found by directly manipulating the XAML markup tree, because Silverlight creates many additional intermediate controls in the rendered output.
- Silverlight provides LogicalTreeHelper and VisualTreeHelper helper classes in order to find the controls in a rendered Silverlight page. But, these classes are mostly useful to find the immediate parents and children only.
- The XamlQuery works for all controls in Silverlight, not only for container controls like Grid and Panel; because even primitive controls like ContentControl can contain any other control like Grid, TreeView inside their templates (data-templates and control-templates).
- XamlQuery hides the complexity of finding controls using styles that are defined elsewhere, like merged resource dictionaries or application XAML markup (App.xaml).
- The controls of specific type or a range of types (using base class) can be found easily by the use of type-selectors. For example, using Shape as a type-selector will return all shape based controls like Rectangle, Line, Ellipse, etc.