
Visual Basic (Declaration) | |
---|---|
Public Class BindingDescriptor |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As BindingDescriptor |
C# | |
---|---|
public class BindingDescriptor |
Delphi | |
---|---|
public class BindingDescriptor |
JScript | |
---|---|
public class BindingDescriptor |
Managed Extensions for C++ | |
---|---|
public __gc class BindingDescriptor |
C++/CLI | |
---|---|
public ref class BindingDescriptor |
BindingDescriptor is one of many functionality provided in ClientUI Advanced Binding Framework. To learn more about this see Data Binding Overview.
BindingDescriptor has three modes of binding that you can choose from, they are FindAncestor, FindName and Self. Each of this mode has different purpose and different settings.
FindAncestor
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 | ![]() |
---|---|
<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# | ![]() |
---|---|
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.
FindName
FindName is used to bind the target with an element with specific name. In this mode, you specify the ElementName that the target will be bound to.
The following example shows how to use FindName mode to bind the target with an element with the specific name specified in ElementName property.
XAML | ![]() |
---|---|
<Grid Height="400" Width="550" x:Name="MainContainer" > <Intersoft:UXProgressBar Height="20" Maximum="700"> <Intersoft:BindingFramework.Binding> <Intersoft:BindingDescriptor TargetProperty="Value" SourceProperty="Width" Mode="FindName" ElementName="MainContainer"/> </Intersoft:BindingFramework.Binding> </Intersoft:UXProgressBar> </Grid> |
This sample bind the Value property of UXProgressBar to MainContainer Width property using FindName.
Self
Self is used to bind the target within itself. You can bind one property with other property within the same element using this mode without needing to specify element name each time.
The following example shows how to use Self mode to bind Text property of UXTextBox to its BorderBrush.
XAML | ![]() |
---|---|
<Intersoft:UXTextBox BorderThickness="4" Text="#FFFF0000" HorizontalAlignment="Center" VerticalAlignment="Center"> <Intersoft:BindingFramework.Binding> <Intersoft:BindingDescriptor TargetProperty="BorderBrush" SourceProperty="Text" Mode="Self" Converter="{StaticResource ColorConverter}" /> </Intersoft:BindingFramework.Binding> </Intersoft:UXTextBox> |
Intersoft.Client.Framework.BindingDescriptor
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