Export (0) Print
Expand All

RelativeSource.AncestorType Property

Gets or sets the type of ancestor to look for.

Namespace: System.Windows.Data
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public Type AncestorType { get; set; }
/** @property */
public Type get_AncestorType ()

/** @property */
public void set_AncestorType (Type value)

public function get AncestorType () : Type

public function set AncestorType (value : Type)

 For XAML information, see RelativeSource MarkupExtension. 

Property Value

The type of ancestor. The default value is a null reference (Nothing in Visual Basic).

Exception typeCondition

InvalidOperationException

The RelativeSource is not in the FindAncestor mode.

If the Mode property is not set explicitly, setting the AncestorType or the AncestorLevel property will implicitly lock the Mode property value to FindAncestor.

The following returns the second ItemsControl encountered on the upward path starting at the target element of the binding.

Binding myBinding = new Binding();
// Returns the second ItemsControl encountered on the upward path
// starting at the target element of the binding
myBinding.RelativeSource = new RelativeSource(
    RelativeSourceMode.FindAncestor, typeof(ItemsControl), 2);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft