TreeListBoxItemAdapter.OnDragHover() difficulty casting targetItem to expected model type

Grids for WPF Forum

Posted 1 month ago by Alex George - CNC Software
Version: 24.1.2
Avatar

Hello,
I am trying to override the TreeListBoxItemAdapter.OnDragHover function so that I can selectively choose whether to auto-expand based on the type of the model

However, unlike the other overridable functions (e.g. OnDrop), I am not having success casting targetItem into the model type I expect.
It seems that in this function, targetItem is an unknown ActiproSoftware.Internal type (TreeNode?) and it is wrapping the model. I am not sure how to get at the model that I need.

   public override TreeItemExpandability OnDragHover(DragEventArgs e, TreeListBox targetControl, object targetItem)
   {
	// this cast fails. targetItem is an unknown type wrapping the TreeNodeModel
       var targetModel = targetItem as TreeNodeModel;
       return base.OnDragHover(e, targetControl, targetItem);
   }


I expected this function to work similar to OnDrop, and I would be able to cast to my expected model type like this:

public override void OnDrop(DragEventArgs e, TreeListBox targetControl, object targetItem, TreeItemDropArea dropArea) {
	var originalEffects = e.Effects;
	e.Effects = DragDropEffects.None;

	// If the drag is over an item and there is item data present...
	var targetModel = targetItem as TreeNodeModel;

I could use some guidance or an example on how to properly override OnDragHover to cast the targetItem to its proper type and get the model within it.
Thank you

Comments (2)

Answer - Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Alex,

Thank you for letting us know.  We confirmed this as a bug and have updated it to pass the correct target item for the upcoming maintenance release, which should be out fairly soon.


Actipro Software Support

Posted 1 month ago by Alex George - CNC Software
Avatar

Thank you

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.