New User?   Join Now     Login            Forgot Password?    
XamlQuery v1.2
XamlQuery API
Posted on Aug-08-2010 (5438 hits)

The following are the methods of ControlSet class. All the methods of XamlQuery returns ControlSet object. These methods are explained in Using XamlQuery.

Filter Methods

These methods reduce the set of matched controls to those that pass a criteria (defined by the method).

  • FilterByType() method finds and returns controls of specified type. For example, you can find all text-boxes in a set of input controls.
  • FilterByTypes() method finds and returns controls whose type is any one of given list of types. For example, you can find all text-boxes and combo-boxes in a set of input controls.
  • FilterByProperty() method finds and returns controls whose property value matches a specified criteria. The string representation of property value is used to find the controls.
  • RemoveByType() method removes controls of specified type from the ControlSet.
  • RemoveByTypes() method removes controls (from ControlSet) whose type is any one of given list of types.
  • Not() method removes the given list of controls and returns the resultant ControlSet.
  • Even() returns even controls. Since index is zero-based, it returns first-control, third-control, and so on.
  • Odd() returns odd controls. Since index is zero-based, it returns second-control, fourth-control, and so on.
  • Gt() returns all controls at index greater than specified index. Since index is zero-based, it returns (i + 1)th to (n - 1)th controls.
  • Lt() returns all controls at index lesser than specified index. Since index is zero-based, it returns (0)th to (i - 1)th controls.
  • Enabled() finds all enabled controls (using IsEnabled property of controls that extend from Control class).
  • Disabled() finds all disabled controls (using IsEnabled property of controls that extend from Control class).
  • Visible() finds all visible controls. (using Visibility property of controls that extend from UIElement class).
  • Invisible() finds all invisible controls. (using Visibility property of controls that extend from class).
  • Checked() finds all checked controls (like checkboxes) (using IsChecked property of controls that extend from ToggleButton class.
  • Unchecked() - finds all unchecked controls (like checkboxes) (using IsChecked property of controls that extend from ToggleButton class.

Value-Related Methods

These methods operate on property values.

  • SetValue() method sets the specified property of all controls in the ControlSet to a specified value.
  • GetValue() method gets the specified property value of all controls in the ControlSet. It returns List<object> instance.
  • SetBinding() method attaches a binding to the matched controls, using the provided binding object.
  • ClearValue() method clears the local value of a specified property.
  • Val() method returns current value of first control in the ControlSet. For TextBlock and TextBox, it returns Text property; for Selector controls (like ListBox, ComboBox), it returns SelectedItem property.
  • Data() method gets or sets an arbitrary value to all controls in the ControlSet. Any number of objects can be assigned to a control, each value identified by a string (key). This is similar to having multiple Tag properties for a Silverlight control.

Visibility-Related Methods

These methods are used to hide/show controls, with optional animation. The speed of animation and the opacity can be specified through arguments.

  • Hide() method hides all the controls in ControlSet (without animation).
  • Show() method displays all the controls in ControlSet (without animation).
  • Toggle() method alternates the visibility of controls (without animation).
  • FadeOut() method hides the controls by fading them to transparent.
  • FadeIn() method displays the controls by fading them to opaque.
  • FadeTo() method sets the opacity of controls to a specified value.
  • FadeToggle() method alternates the transparency of controls.
  • SlideUp() method hides the matched controls with a sliding motion.
  • SlideDown() method displays the matched controls with a sliding motion.
  • SlideTo() method sets the height of matched controls to a specified value.
  • SlideToggle() method displays or hides the matched controls with a sliding motion.

Animation Methods

These methods are used to carry out a custom animation on a given property.

  • Animate() method animates a control based on a given property. The speed of animation and begin/end values for property can be specified through arguments. An optional callback function can be specified, which is invoked after the animation is finished. This method currently supports properties of data-type double (like Opacity, Width, Height).

Event-Related Methods

These methods simplifies the tasks related to event-handling. The events can be specified by high-level event names, defined by EventType enumeration. For more information, see Event Handling in XamlQuery.

  • AddHandler() method adds a routed event handler for a specified routed event of matched controls.
  • RemoveHandler() method removes the specified routed event handler from matched controls.
  • Bind() method binds a event handler method to an event specified by EventType. The EventType is an enumeration that assists event-handing mechanism using high-level names.
  • Trigger() method invokes an event attached using Bind method. The event specified by EventType is fired immediately without the actual event (like mouse moved or key pressed by user) being occurred.

Each event specified by EventType has two helper methods associated with it. These methods are used to trigger or bind the corresponding event. These methods are actually shortcuts to Bind() and Trigger() methods.

Layout-Related Methods

These methods operate on layout attributes like position, size, etc.

  • Detach() method deletes/removes all controls in the ControlSet from the rendered output. The removed controls will no longer be available in the rendered output of Silverlight. The controls that are inside a container control (like Grid, StackPanel, WrapPanel, etc.) can be detached/removed. The container controls are those that are extended from Panel.
  • DetachByType() method deletes/removes all controls of specified type from the rendered output.
  • DetachByTypes() method deletes/removes all controls of specified types from the rendered output.
  • Empty() method removes all controls from a container control (like Grid, StackPanel, WrapPanel, etc.)
  • Width() method returns the actual-width of first control in the ControlSet.
  • Height() method returns the actual-height of first control in the ControlSet.
  • Position() method returns the position of first control in the ControlSet. The position is calculated with reference to its immediate parent or container control.


About      Terms      Contact