Get Current row on mouse hover

6 posts, 2 answers
  1. Ishita
    Ishita avatar
    30 posts
    Member since:
    Nov 2013

    Posted 25 Apr 2014 Link to this post

    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.
  2. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 25 Apr 2014 Link to this post

    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.
     
  3. DevCraft banner
  4. Ishita
    Ishita avatar
    30 posts
    Member since:
    Nov 2013

    Posted 25 Apr 2014 in reply to Yoan Link to this post

    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 ?!!
  5. Answer
    Chirag
    Chirag avatar
    37 posts
    Member since:
    May 2011

    Posted 25 Apr 2014 Link to this post

    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 
  6. Answer
    Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 30 Apr 2014 Link to this post

    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.
     
  7. Ishita
    Ishita avatar
    30 posts
    Member since:
    Nov 2013

    Posted 01 May 2014 Link to this post

    yes. Thanks Given solution helped! :) 
Back to Top
DevCraft banner