Binding Position and dynamically adding items

3 posts, 0 answers
  1. Jerome
    Jerome avatar
    87 posts
    Member since:
    Aug 2010

    Posted 01 Nov 2012 Link to this post

    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. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 06 Nov 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Vladimir Skvortsov
    Vladimir Skvortsov avatar
    5 posts
    Member since:
    Oct 2009

    Posted 27 Apr Link to this post

    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.

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

Back to Top