Intersoft ClientUI Documentation
AncestorLevel Property
See Also  Send Feedback
Intersoft.Client.Framework Namespace > BindingDescriptor Class : AncestorLevel Property






Gets or sets the level of ancestor to look for, in FindAncestor mode. Use 1 to indicate the one nearest to the binding target element.

Syntax

Visual Basic (Declaration) 
Public Property AncestorLevel As Integer
Visual Basic (Usage)Copy Code
Dim instance As BindingDescriptor
Dim value As Integer
 
instance.AncestorLevel = value
 
value = instance.AncestorLevel
C# 
public int AncestorLevel {get; set;}
Delphi 
public read-write property AncestorLevel: Integer; 
JScript 
public function get,set AncestorLevel : int
Managed Extensions for C++ 
public: __property int get_AncestorLevel();
public: __property void set_AncestorLevel( 
   int value
);
C++/CLI 
public:
property int AncestorLevel {
   int get();
   void set (    int value);
}

Remarks

FindAncestor is used to bind the target with a specific ancestor element type defined in specific ancestor level range. This mode is commonly used when you know that a specific ancestor element type existed on certain level.

In this mode, you specify the AncestorType to determine the type of the target that will be bound and the AncestorLevel to determine how far it will look up for the ancestor with types specifed in AncestorType.

The default value of AncestorLevel is 1, so it will look at up one time and check whether the current ancestor match the type specified in AncestorType. If it matches, it will continue with the binding process.

The following example shows how to use FindAncestor mode to bind the elements inside ItemTemplate of a UXListBox to UXListBoxItem as their ancestor.

XAML Copy Code
<Intersoft:UXListBox ItemsSource="{Binding Collection}" ImageMemberPath="Image" ItemContentType="ContentAndImage" 
                        ItemImageHeight="32" ItemImageWidth="32" HorizontalScrollBarVisibility="Disabled">
    <Intersoft:UXListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding Name}"/>
                <StackPanel Orientation="Horizontal">
                    <Intersoft:BindingFramework.Binding>
                        <Intersoft:BindingDescriptor TargetProperty="Visibility" SourceProperty="IsSelected"
                                                                    Mode="FindAncestor" AncestorType="UXListBoxItem"
                                                                    Converter="{StaticResource VisibilityConverter}"/>
                    </Intersoft:BindingFramework.Binding>
                    <Intersoft:UXHyperlinkButton Content="Details" IsToggleButton="False" Foreground="Navy"/>
                    <Intersoft:UXHyperlinkButton Content="Order" IsToggleButton="False" Foreground="Navy" Margin="8,0,0,0"/>
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </Intersoft:UXListBox.ItemTemplate>
</Intersoft:UXListBox>
C# Copy Code
public class VisibilityConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is bool && targetType == typeof(Visibility))
        {
            if ((bool)value)
                return Visibility.Visible;
            else
                return Visibility.Collapsed;
        }

        return value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is Visibility && targetType == typeof(bool))
        {
            if (((Visibility)value) == Visibility.Visible)
                return true;
            else
                return false;
        }

        return value;
    }
}

This sample bind the Visibility property of StackPanel to the IsSelected property of UXListBoxItem using FindAncestor. Notice that the BindingDescriptor also supports IValueConverter.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.