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

Binding Position and dynamically adding items

2 Answers 220 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Jerome
Top achievements
Rank 1
Jerome asked on 02 Nov 2012, 12:38 AM
I have a RadTileView, with ItemsSource set to an ObservableCollection. RadTileViewItem.Position is configured to bind to a property on each item named Position. This seems to work fine for the initial load... however, when the Position property is updated, the RadTileView does not reorder the tiles.

I think it probably has something to do with items being added one at a time to the ObservableCollection, and then their Position values are being rebuilt en-mass.

Are there any specifics I should know about here? Basically I need a list of tiles, with items being added and removed on the fly, and also changing position.

[EDIT]

Okay. I have the reordering working. The issue seems to be that if the Binding on Position is not TwoWay, it is simple ignored, and the order in the collection controls the order of the tiles. This seems odd, as I don't desire TwoWay binding... I just want to be able to change it.

I'm still suffering from two issues. One, is the animations don't work. The tiles don't slide around. I have set a ReorderingDuration as well as ElasticEase as the ReorderingEasing. However, the tiles still just jump.

Second, there seems to still be something wrong with adding tiles. Sometimes, when I add items to the underlying collection, the tiles aren't actually created. Theres just blank spaces where the tiles should be.

[EDIT]

Okay. I've figured most of this out. Position must be two way, because TileView does not simply read from Position, but adjusts the positions of other tiles in order to reorder them. So if I change the position of an object in the collection, the TileView will go and change the positions of OTHER elements in the collection. And it looks like it only really likes to change the position of one thing at a time. So, fine. Instead of rebuilding all the positions in a loop; I'm only setting the position of the first item in the collection that's at the incorrect position. The loop then comes around again after 1 second, and does the same thing to the next item. And it only shifts it by one position at a time. So, if the position is > than it should be, I Position-- it. If it's less than it should be, I Position++ it. Eventually they are all the proper value.

This is kind of obnoxious. It'd be easier of I could just reset the positions of all items of the collection to the proper position and have the TileView move them around properly.

Second, my animations are still broken. But I figured out why. I'm overriding the Template of RadTileViewItem in order to remove the Header. For some reason, this destroys the animations. I still need help figuring out how to fix the animations.

[EDIT]

Success! I had to put TWO unnamed, unused Grid elements as the root of the RadTileViewItem.Template. That is totally undocumented. Somebody should document this somehow. =)

2 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 06 Nov 2012, 05:03 PM
Hi Jerome,

I'm glad to see that you've managed to get over all your issues. And we will make sure to update the documentation accordingly to your suggestions.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Vladimir Skvortsov
Top achievements
Rank 1
answered on 27 Apr 2016, 09:27 AM

[quote]Second, there seems to still be something wrong with adding tiles. Sometimes, when I add items to the underlying collection, the tiles aren't actually created. Theres just blank spaces where the tiles should be.[/quote]

Hi, Jerome, maybe it's too late, but maybe you found workaround for this?

Tags
TileView
Asked by
Jerome
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Vladimir Skvortsov
Top achievements
Rank 1
Share this question
or