Change cursor for LightVisualButtonElement

3 posts, 1 answers
  1. Patrick
    Patrick avatar
    43 posts
    Member since:
    Aug 2018

    Posted 03 Oct 2019 Link to this post

    Hello,

    I am currently changing the design for a ListView item (IconView) and have created a custom class which inherits an IconListViewVisualItem.

    One of the elements in the custom class is a LightVisualButtonElement.

    I would like to change the cursor for this element into the Cursors.Hand.

    Is there a way to accomplish this? Or do I need to use another element type?

     

    Best regards

    Patrick Vossen

  2. Answer
    Nadya
    Admin
    Nadya avatar
    486 posts

    Posted 04 Oct 2019 Link to this post

    Hello Patrick,

    You can change cursor over the button in your custom IconListViewVisualItem by using the MouseMove event. You should override the OnMouseMove event as well in order to reset the cursor and turn it back to the arrow for the other elements. Please refer to the following code snippet which demonstrates this approach:

    public class MyCustomIconListViewVisualItem : IconListViewVisualItem
    {
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(IconListViewVisualItem);
            }
        }
    
        RadButtonElement buttonElement = new RadButtonElement();
        StackLayoutElement stack = new StackLayoutElement();
    
        protected override void CreateChildElements()
        {
            base.CreateChildElements();
    
            this.buttonElement.MouseMove += ButtonElement_MouseMove;
    
            stack.Orientation = Orientation.Vertical;
            
            stack.Children.Add(buttonElement);
            this.Children.Add(stack);
        }
    
        private void ButtonElement_MouseMove(object sender, MouseEventArgs e)
        {
            this.ElementTree.Control.Cursor = Cursors.Hand;
        }
    
        protected override void SynchronizeProperties()
        {
            base.SynchronizeProperties();
            this.Text = string.Empty;
            this.buttonElement.Text = this.Data.Text;
        }
    
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
    
            this.ElementTree.Control.Cursor = Cursors.Arrow;
        }
    }
    

    I hope this helps. Should you have any other questions, I will be glad to help.

    Regards,
    Nadya
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Patrick
    Patrick avatar
    43 posts
    Member since:
    Aug 2018

    Posted 07 Oct 2019 in reply to Nadya Link to this post

    Hi Nadya,

    Thanks for the solution.

     

    Grtz Patrick

Back to Top