RadTileList.SelectedItem works when stepping thru code but not during normal runtime?

0 Answers 64 Views
TileList
Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
Rob A. asked on 28 Jun 2021, 12:20 AM | edited on 28 Jun 2021, 12:20 AM

I'm populating a RadTileList using AutoGeneratingFile and setting Tile.Background to a ImageBrush, works well.  In the RadTileList.Loaded event (which seems to be happen only after all AutoGeneratingTile events have completed) I set the RadTileList.SelectedItem.

This works great when I step thru the code in debug mode.  However, if I don't step thru the code the SelectedItem will NOT be checked in the RadTileList?

Don't know how to proceed with this?

Any help?

Cheers, Rob.

 

Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 28 Jun 2021, 12:41 AM | edited

UPDATE: so the issue appears to be the MouseLeftButtonDownEvent on RadWindow containing the RadGridView is bubbling up to the new RadWindow1 RadTileList control (that gets loaded during the MouseLeftButtonDownEvent) and setting the selected item as if I operated a mouse left button click (which I did not).

I've tried setting e.Handled = True but the event still seems to bubble up to RadWindow1.RadTileList which then "selects" whatever Tile the mouse is over.

Also even tried IsHitTest and IsEnabled on the RadTileList still accepted the MouseLeftDownEvent.

I'm pretty sure this isn't "be design" behavior and how I prevent this problem or work around it?
Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 28 Jun 2021, 02:15 AM

UPDATE 2: I gave up trying to prevent the RadTileList.SelectedItem focus to being where the mouse cursor happen to be at the time the RadWindow1 displays. My work around was to setup a DispatcherTimer (100ms) to run once and set the RadTileList.SelectedItem. So now my next issue, how to Scroll the Tiles so that the selected tile is within view?
Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 28 Jun 2021, 02:31 AM

UPDATE 3: I attempted to use RadTileList.BringIntoView(RadTileList.SelectedItem), but this didn't work. I noticed other controls have a ScrollIntoView but I can't find anything similar for RadTileLIst?
Martin Ivanov
Telerik team
commented on 30 Jun 2021, 11:12 AM | edited

For the original issue, can you send over some additional information like code snippets, a sample project or a video showing the exact setup, so I can check the troublesome behavior on my side?

About the scrolling question, there is no bring-into-view support in the RadTileList control. For this type of feature, you can take a look at the RadTileView control.

Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 30 Jun 2021, 04:13 PM

Thanks for all the responses Martin. RadTileView is more heavy weight than I need, hence using RadTileList ... do you have an code that can help me scroll the SelectedItem into view?
Martin Ivanov
Telerik team
commented on 01 Jul 2021, 06:49 AM

I haven't posted a suggestion for the scrolling because I am afraid that there is no convenient API that will allow you to do this. Currently, the only approach that I can offer is to get the ScrollViewer control of the RadTileList and call its ScrollToHorizontalOffset and ScrollToVerticalOffset methods. To get the ScrollViewer, you can use the FindChildByType<T>()  extension method.

var scrollViewer = this.tileView.FindChildByType<ScrollViewer>();

However, the troublesome part here will be how to get the correct offset. This is because of the UI virtualization of the control and the possibility to use different sizes for the tiles. If you use a single size (like TileType=Double which is the default one), you can assume that each tile has a fixed size (lets say 100x100) and based on this information, along with the searched item index and the size of the control, you can calculate some offset which you can use with the ScrollViewer's methods.

No answers yet. Maybe you can help?

Tags
TileList
Asked by
Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or