Binding to UIElement DProperty
-
Wednesday, March 26, 2008 11:01 PM
Hello,
I'm sure this is well-documented somewhere... Let's say you have a grid panel that contains some rows and columns, each cell containing a textblock. What is the syntax for binding the Text of any one of those textblocks to the row (or column) index in which it is placed within the grid (ie, syntax in XAML for TextBlock.Text = TextBlock.GetValue(Grid.Row)).
Thank you,
-Craig
All Replies
-
Friday, March 28, 2008 4:37 AM
Hi:
It's not supported in Silverlight yet. In WPF you can try this:
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox x:Name="TextBox1" Text="{Binding (Grid.Row)}" Grid.Row="0" Grid.Column="1"></TextBox>
</Grid>public Window1()
{
InitializeComponent();
TextBox1.DataContext = TextBox1;
}
Regards

