This is a migrated thread and some comments may be shown as answers.

[Solved] Get TextBlock in a tooltip image in a Cell

2 Answers 126 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paolo
Top achievements
Rank 1
Paolo asked on 14 Jul 2009, 05:05 PM
Hi, I have a gridview with a column like this:

 

 

<telerikGridView:GridViewDataColumn HeaderText="Sal" x:Name="ColonnaSal" Width="100" >

 

 

 

<telerikGridView:GridViewDataColumn.CellTemplate >

 

 

 

<DataTemplate>

 

 

 

<Grid>

 

 

 

<Grid.ColumnDefinitions>

 

 

 

<ColumnDefinition Width="0.5*" />

 

 

 

<ColumnDefinition Width="0.5*"/>

 

 

 

</Grid.ColumnDefinitions>

 

 

 

<Grid.RowDefinitions>

 

 

 

<RowDefinition />

 

 

 

<RowDefinition />

 

 

 

</Grid.RowDefinitions>

 

 

 

 

 

 

 

 

<TextBlock Grid.Row="0" Grid.Column="0" x:Name="FldNSAL" Grid.ColumnSpan="2" HorizontalAlignment="Center" Text="{Binding nsal}" ></TextBlock>

 

 

 

 

 

 

 

 

<Image Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Height="24" Width="24" Source="images/add_favority_24x24.png" Cursor="Hand">

 

 

 

<ToolTipService.ToolTip>

 

 

 

<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="5" >

 

 

 

<TextBlock HorizontalAlignment="Right" Text="Insertt" ></TextBlock>

 

 

 

<TextBlock  HorizontalAlignment="Right" x:Name="FldInfo" Text="---" Width="80"></TextBlock>

 

 

 

</StackPanel>

 

 

 

</ToolTipService.ToolTip>

 

 

 

</Image>

 

 

 

 

 

<Image Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Height="24" Width="24" Source="images/delete_favorite_24x24.png" Cursor="Hand">

 

 

 

<ToolTipService.ToolTip>

 

 

 

<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="5" >

 

 

 

<TextBlock HorizontalAlignment="Right" Text="Remove:" ></TextBlock>

 

 

 

</StackPanel>

 

 

 

</ToolTipService.ToolTip>

 

 

 

</Image>

 

 

 

</Grid>

 

 

 

 

</DataTemplate>

 

 

 

</telerikGridView:GridViewDataColumn.CellTemplate>

 

 

 

</telerikGridView:GridViewDataColumn>

so I have a ROW, with an Image, with a tooltip with a TextBlock.
I need to access to that textblock (X:Name="FldInfo") to write some information, but i cannot.
I try with 

 

RowLoaded event to access to all row:

 

Public

 

Sub GrigliaDettagli_RowLoaded(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.GridView.RowLoadedEventArgs)

 

    Dim

 

riga As Telerik.Windows.Controls.GridView.GridViewRowItem

 

    riga = e.Row

 

    Dim a As List(Of TextBlock) = riga.ChildrenOfType(Of TextBlock)()

 

 

    Dim ObjTesto As TextBlock = a.Where(Function(tb) tb.Name = "FldInfo").FirstOrDefault

 

end sub

but ObjTesto return NOTHING

Thanks in Advance.
Paolo

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 15 Jul 2009, 06:21 AM
Hello Paolo,

You can use Loaded event of the TextBlock instead. Here is an example:

XAML
<UserControl x:Class="SilverlightApplication4.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    <Grid> 
        <telerik:RadGridView Name="RadGridView1" AutoGenerateColumns="False"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="CustomerID" DataMemberBinding="{Binding CustomerID}"
                    <telerik:GridViewDataColumn.CellTemplate> 
                        <DataTemplate> 
                            <Button Width="50" Height="50" Cursor="Hand"
                                <ToolTipService.ToolTip> 
                                    <StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="5" > 
                                        <TextBlock HorizontalAlignment="Right" Text="Insertt" ></TextBlock
                                        <TextBlock  HorizontalAlignment="Right" x:Name="FldInfo" Text="---" Width="80" Loaded="FldInfo_Loaded"></TextBlock> 
                                    </StackPanel> 
                                </ToolTipService.ToolTip> 
                            </Button> 
                        </DataTemplate> 
                    </telerik:GridViewDataColumn.CellTemplate> 
                </telerik:GridViewDataColumn> 
                <telerik:GridViewDataColumn Header="CompanyName" DataMemberBinding="{Binding CompanyName}" /> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </Grid> 
</UserControl> 
 


VB.NET
Imports System 
Imports System.Collections.Generic 
Imports System.Linq 
Imports System.Net 
Imports System.Windows 
Imports System.Windows.Controls 
Imports System.Windows.Documents 
Imports System.Windows.Input 
Imports System.Windows.Media 
Imports System.Windows.Media.Animation 
Imports System.Windows.Shapes 
 
Partial Public Class Page 
    Inherits UserControl 
    Public Sub New() 
 
        InitializeComponent() 
 
        RadGridView1.ItemsSource = From i In Enumerable.Range(0, 5) Select New Customer() 
 
    End Sub 
 
    Private Sub FldInfo_Loaded(ByVal sender As System.ObjectByVal e As System.Windows.RoutedEventArgs) 
        Dim current As Customer = CType(sender, TextBlock).DataContext 
    End Sub 
End Class 
 
 
Public Class Customer 
    Dim _CustomerID As Integer 
    Dim _CompanyName As String 
 
    Public Property CustomerID() As Integer 
        Get 
            Return _CustomerID 
        End Get 
        Set(ByVal value As Integer
            _CustomerID = value 
        End Set 
    End Property 
    Public Property CompanyName() As String 
        Get 
            Return _CompanyName 
        End Get 
        Set(ByVal value As String
            _CompanyName = value 
        End Set 
    End Property 
End Class 


Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paolo
Top achievements
Rank 1
answered on 15 Jul 2009, 08:12 AM
Perfect!
It work!
Many thanks

Paolo
Tags
GridView
Asked by
Paolo
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Paolo
Top achievements
Rank 1
Share this question
or