DependencyObject.SetValue method

Expand
0 out of 2 rated this helpful - Rate this topic

DependencyObject.SetValue method

[This documentation is preliminary and is subject to change.]

Sets the local value of a dependency property on a DependencyObject.

Syntax


public void SetValue(
  DependencyProperty dp, 
  object value
)

Parameters

dp

Type: DependencyProperty

The identifier of the dependency property to set.

value

Type: System.Object [.NET] | Platform::Object [C++]

The new local value.

Examples

This example shows a simple dependency property declaration. A call to SetValue constitutes the entirety of the set accessor implementation for the property wrapper of the new dependency property. For more examples, see Custom dependency properties.


public class Fish : Control
{
    public static readonly DependencyProperty SpeciesProperty =
    DependencyProperty.Register(
    "Species",
    typeof(String),
    typeof(Fish), null
    );
    public string Species
    {
        get { return (string)GetValue(SpeciesProperty); }
        set { SetValue(SpeciesProperty, (string)value); }
    }
}


Requirements

Minimum supported client

Windows 8 Release Preview

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

See also

DependencyObject
Custom dependency properties
Dependency properties overview
XAML user and custom controls sample

 

 

Build date: 5/22/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD