如何在Silverlight中从文本块获取值

如何在Silverlight中从文本块获取值

本文介绍了如何在Silverlight中从文本块获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,如何从文件后面的Silverlight代码中的文本块中获取值非常紧急


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


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






这很紧急,


在此先感谢

Sudhir Srivastava






This is very urgent,


Thanks in advance

Sudhir Srivastava

推荐答案

<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;
           MessageBox.Show(strBlockName);
       }




当用户单击树图节点块时,他会得到用
编写的文本
文字块




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

Textblock


这篇关于如何在Silverlight中从文本块获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 00:25