Bagikan melalui


GetValue

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

Gets the value of the specified property.

retval = object.GetValue(propertyName)

Arguments

propertyName

string

The name of the property to get the value for.

Return Value

Type: object

The value of the specified property.

Managed Equivalent

DependencyObject.GetValue- note that in the managed API, this method is exclusively for dependency properties, and requires a dependency property identifier (not just a name as a string).

Remarks

You can use the GetValue method to get the value of any Silverlight property. However, you generally do not need this method to get property values, because all Silverlight properties support a more direct property syntax in JavaScript.

You can also use GetValue to get the value of Silverlight attached properties such as Canvas.Left. In this case, the attached property name consists of the owner class name for the attached property, a dot, and the attached property name: value = object.GetValue("ownerType.propertyName"). However, attached properties also support a more direct property syntax, in the form value = object["ownerType.propertyName"].

Example

The following JavaScript example shows to get a property value by using both the GetValue method and the typical property notation.

function onMouseLeftButtonUp(sender, index)
{
    // Get the property value using the GetValue method.
    var opacity = sender.getValue("opacity");

    // Get the property value using the equivalent "." notation.
    var opacity = sender.opacity;

    alert("Opacity = " + opacity);
}

Applies To

Accessibility Object (Silverlight JSAPI)

ArcSegment

BeginStoryboard

BezierSegment

BitmapImage (Silverlight 2)

Border (Silverlight 2)

Brush (abstract)

Canvas

Color

ColorAnimation

ColorAnimationUsingKeyFrames

ColorKeyFrame (abstract)

ColorKeyFrameCollection

DeepZoomImageTileSource (Silverlight 2)

DependencyObject (abstract)

DiscreteColorKeyFrame

DiscreteDoubleKeyFrame

DiscreteObjectKeyFrame (Silverlight 2)

DiscretePointKeyFrame

DoubleAnimation

DoubleAnimationUsingKeyFrames

DoubleKeyFrame (abstract)

DoubleKeyFrameCollection

Downloader

DrawingAttributes

Duration

Ellipse

EllipseGeometry

EventTrigger

Geometry (abstract)

GeometryCollection

GeometryGroup

Glyphs

GradientStop

GradientStopCollection

Image

ImageBrush

InkPresenter

Inlines

KeySpline

KeyTime

Line

LinearColorKeyFrame

LinearDoubleKeyFrame

LinearGradientBrush

LinearPointKeyFrame

LineBreak

LineGeometry

LineSegment

Matrix

MatrixTransform

MediaAttribute

MediaAttributeCollection

MediaElement

MultiScaleImage (Silverlight 2)

ObjectAnimationUsingKeyFrames (Silverlight 2)

ObjectKeyFrameCollection (Silverlight 2)

PasswordBox (Silverlight 2)

Path

PathFigure

PathFigureCollection

PathGeometry

PathSegment (abstract)

PathSegmentCollection

Point

PointAnimation

PointAnimationUsingKeyFrames

PointKeyFrame (abstract)

PointKeyFrameCollection

PolyBezierSegment

Polygon

Polyline

PolyLineSegment

PolyQuadraticBezierSegment

Popup (Silverlight 2)

QuadraticBezierSegment

RadialGradientBrush

Rect

Rectangle

RectangleGeometry

RepeatBehavior

ResourceDictionary

RotateTransform

Run

RuntimeErrorEventArgs

ScaleTransform

SkewTransform

SolidColorBrush

SplineColorKeyFrame

SplineDoubleKeyFrame

SplinePointKeyFrame

StackPanel (Silverlight 2)

Storyboard

Stroke

StrokeCollection

StylusInfo

StylusPoint

StylusPointCollection

TextBlock

TextBox (Silverlight 2)

Timeline (abstract)

TimelineCollection

TimelineMarker

TimelineMarkerCollection

TimelineMarkerEventArgs

TimeSpan

TransformCollection

TransformGroup

TranslateTransform

TriggerActionCollection

TriggerCollection

VisualCollection

VideoBrush

See Also

Reference