Click here to Skip to main content
15,849,996 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My question is, how to get the value from textblock in Silverlight code behind file very urgent

<datavis:TreeMap x:Name="treeMapControl" Height="auto" Margin="0" Width="auto" Grid.Row="0" >

                  <myinterpolater:SolidColorBrushInterpolator TargetName="itemBorder" TargetProperty="Background"
                                         DataRangeBinding="{Binding Rate}" From="Red"   To="Green" />
                  <datavis:DoubleInterpolator TargetName="textBlk" TargetProperty="FontSize"
                                         DataRangeBinding="{Binding Rate}" From="8" To="15" />

                  <datavis:TreeMapItemDefinition  ItemsSource="{Binding Children}" ValueBinding="{Binding Rate}" ChildItemPadding="1" x:Uid="{Binding Name}"  >
                          <Border x:Name="itemBorder" BorderBrush="AntiqueWhite" BorderThickness="0.5" ToolTipService.ToolTip="{Binding ToolTip}" MouseLeftButtonDown="treeMapControl_MouseLeftButtonDown" >

                           <TextBlock x:Name="textBlk"  Foreground="White" Text="{Binding Name}" VerticalAlignment="Center" Margin="2,2,0,0"
                                     TextWrapping="Wrap" TextAlignment="Center"/>





This is very urgent,

Thanks in advance

Sudhir Srivastava
Updated 11-Nov-11 2:43am

1 solution

I solved this problem with another way,

<TextBlock  x:Name="textBlk"  Foreground="Transparent" Text="{Binding Name}"
                                       TextWrapping="Wrap"  MouseLeftButtonDown="textBlk_MouseLeftButtonDown"  HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Margin="0,0,0,0" FontSize="72"  FontWeight="ExtraBold" />

And in code behind

private void textBlk_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
           TextBlock tb = new TextBlock();
           tb = (TextBlock)sender;

           string strBlockName= tb.Text;

When user would click in the treemap node block he would get the text written in

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900