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

Change cursor for LightVisualButtonElement

2 Answers 213 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 03 Oct 2019, 06:54 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 04 Oct 2019, 03:21 PM

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.
0
Patrick
Top achievements
Rank 1
answered on 07 Oct 2019, 08:19 AM

Hi Nadya,

Thanks for the solution.

 

Grtz Patrick

Tags
ListView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or