ColorAnimation.By Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the total amount by which the animation changes its starting value.

Namespace:  System.Windows.Media.Animation
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property By As Nullable(Of Color)
public Nullable<Color> By { get; set; }
<ColorAnimation>
  <ColorAnimation.By>
    <Color>colorString</Color>
  </ColorAnimation.By>
</ColorAnimation>
<ColorAnimation By="colorString"/>
-or-
<ColorAnimation By="referenceToColor"/>

XAML Values

  • colorString
    A color specified as a string, using a variety of possible formats, including predefined named colors. For the full list of available string formats that can specify a Color as an attribute, see Color.

  • referenceToColor
    A {StaticResource} reference or other reference to an existing color. You can define a Color in a ResourceDictionary in the form <Color x:Key="key">colorString</Color>.

Property Value

Type: System.Nullable<Color>
The total amount by which the animation changes its starting value. The default is nulla null reference (Nothing in Visual Basic).

Remarks

Dependency property identifier field: ByProperty

Use the By property when you want to animate a value "by" a certain amount, rather than specifying a starting or ending value. You may also use the By property with the From property. The following table summarizes how the From, To, and By properties can be used together or separately to determine an animation's target values.

Properties Specified

Resulting Behavior

From

The animation progresses from the value specified by the From property to the base value of the property being animated or to a previous animation's output value, depending on how the previous animation is configured.

From and To

The animation progresses from the value specified by the From property to the value specified by the To property.

From and By

The animation progresses from the value specified by the From property to the value specified by the sum of the From and By properties.

To

The animation progresses from the animated property's base value or a previous animation's output value to the value specified by the To property.

By

The animation progresses from the base value of the property being animated or a previous animation's output value to the sum of that value and the value specified by the By property.

NoteNote:

If you set both the To and By properties, the To property takes precedence and the By property is ignored.

To use other interpolation methods or animate between more than two target values, use a ColorAnimationUsingKeyFrames object.

To set a ColorAnimation attribute to null in XAML, use an attribute value of {x:Null}.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.