Click here to Skip to main content
15,890,438 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


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


              <datavis:TreeMap.Interpolators>
                  <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:TreeMap.Interpolators>

              <datavis:TreeMap.ItemDefinition>
                  <datavis:TreeMapItemDefinition  ItemsSource="{Binding Children}" ValueBinding="{Binding Rate}" ChildItemPadding="1" x:Uid="{Binding Name}"  >
                      <DataTemplate>
                          <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"/>
                          </Border>

                      </DataTemplate>


                  </datavis:TreeMapItemDefinition>



              </datavis:TreeMap.ItemDefinition>


          </datavis:TreeMap>





This is very urgent,


Thanks in advance

Sudhir Srivastava
Posted
Updated 11-Nov-11 1:43am
v4

1 solution

I solved this problem with another way,


HTML
<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

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

           string strBlockName= tb.Text;
           MessageBox.Show(strBlockName);
       }



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

Textblock
 
Share this answer
 
v4

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