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

Get Current row on mouse hover

5 Answers 194 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Ishita
Top achievements
Rank 1
Ishita asked on 25 Apr 2014, 10:21 AM
HI, 
          I want Row When it is highlighted. I dont want Selected Row But, Highlighted Row. (Selected Row = Orange Color , Highlighted Row = Yellow Color)
I get NULL in RadtreelistView.CurrentRow.
Find attached files for ease.

5 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 25 Apr 2014, 12:27 PM
Hello,

In order to achieve your goal, you can subscribe to GridView's MouseMove event and get the GridViewRow element by using the ParentOfType<> extension method. Please check the following code snippet for a reference:
public MainPage()
        {
            InitializeComponent();
            this.clubsGrid.MouseMove += clubsGrid_MouseMove;
        }
 
        void clubsGrid_MouseMove(object sender, MouseEventArgs e)
        {
            var element = e.OriginalSource;
            var row = (element as FrameworkElement).ParentOfType<GridViewRow>();
 
            if (row != null)
            {
                //your code
                // Debug.WriteLine((row.Item as Club).StadiumCapacity.ToString());              
            }
        }

I hope this helps.

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Ishita
Top achievements
Rank 1
answered on 26 Apr 2014, 04:31 AM
Yes, It helped me,
 Actually, i want a context menu to be assiciated with this highlighted row and needed highlighted row, mouse move is gonna call all the time, any better solution ?!!
0
Accepted
Chirag
Top achievements
Rank 1
answered on 26 Apr 2014, 04:34 AM
Hello Ishita 

you can achieve your goal  by adding mouse click event on row as below 

<telerik:RadTreeListView x:Name="radTreeListView" AutoGenerateColumns="true"  Grid.Row="1" RowIsExpandedChanged="radTreeListView_RowIsExpandedChanged" RowLoaded="radTreeListView_RowLoaded" >

private void radTreeListView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
     var row = e.Row as TreeListViewRow;
     if (row != null)
     {               
               row.MouseRightButtonUp += row_MouseRightButtonUp;              
     }
}

void row_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
          radTreeListView.SelectedItem =((Telerik.Windows.Controls.GridView.GridViewRow)(sender)).DataContext
}

i hope this will help to you 
0
Accepted
Yoan
Telerik team
answered on 30 Apr 2014, 01:15 PM
Hi Ishita,

As Chirag said, you can use GridView's RowLoaded event. Then you can subscribe to row's MouseEnter event like so:
void clubsGrid_RowLoaded(object sender, RowLoadedEventArgs e)
       {          
           e.Row.MouseEnter += Row_MouseEnter;
       }
 
       void Row_MouseEnter(object sender, MouseEventArgs e)
       {
//your logic here....
           var element = e.OriginalSource;
           var row = (element as FrameworkElement).ParentOfType<GridViewRow>();           
           if (row != null)
           {
               Debug.WriteLine((row.Item as Club).StadiumCapacity.ToString());
           }
       }



Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Ishita
Top achievements
Rank 1
answered on 01 May 2014, 11:32 AM
yes. Thanks Given solution helped! :) 
Tags
TreeListView
Asked by
Ishita
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Ishita
Top achievements
Rank 1
Chirag
Top achievements
Rank 1
Share this question
or