Hello,
I'm struggling to get some events to work on a RadListViewElement, which is a child of a custom RadElement, which in turn is inside another custom RadControl. I guess a few lines of code will help to describe this:
Imports Telerik.WinControls
Imports Telerik.WinControls.UI
Public Class xElement
Inherits RadElement
Private listElement As RadListViewElement
Public Sub New()
'Me.NotifyParentOnMouseInput = True
'Me.ShouldHandleMouseInput = True
'Me.Capture = True
'Me.CaptureOnMouseDown = True
End Sub
Protected Overrides Sub OnLoaded()
MyBase.OnLoaded()
AddHandler listElement.ItemMouseUp, Sub(s, e)
If e.OriginalEventArgs.Button = MouseButtons.Left Then
listElement.SelectedItem = e.Item
End If
End Sub
End Sub
Protected Overrides Sub CreateChildElements()
MyBase.CreateChildElements()
listElement = New RadListViewElement
With listElement
'.ShouldHandleMouseInput = True
'.NotifyParentOnMouseInput = True
'.Capture = True
'.CaptureOnMouseDown = True
.ViewType = ListViewType.ListView
.DataSource = New List(Of String)(New String() {"a", "b", "c"})
End With
Me.Children.Add(listElement)
End Sub
End Class
Imports Telerik.WinControls
<ToolboxItem(True)>
Public Class xControl
Inherits RadControl
Private element As xElement
Public Sub New()
element = New xElement()
RootElement.Children.Add(element)
End Sub
End Class
Some remarks on this piece of code:
- The items in listview react to events like mouseEnter/Leave.
- These items can't be selected by using the mouse, the click event does nothing on them, the action needs to be managed manually, which here is done in the OnLoaded() sub.
- The click event works on other elements inside listView, so, for instance, the scrollbar of the item container can be clicked, the list of items can be scrolled.
So, some events work out-of-the-box and some do not, and a certain event works here but not there, so I'm somewhat confused on what's going on. Anyway, it doesn't seem like the way it's supposed to be, and I'm sure the proper solution is a lot less cumbersome than manually capturing each event and then replicating the original behavior.
I guess I'm just missing something about how TPF works, maybe there's some element not initialized correctly, perhaps I need to enable some property. Any suggestions on this?
Thank you