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

RadTileView databinding and TileViewItem state

3 Answers 143 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Qaiser
Top achievements
Rank 1
Qaiser asked on 23 Jul 2010, 09:32 PM

Hi, 

I am using RadTileView with all the tiles generated using databinding with ViewModel. To make sure all the tiles are of a certain minimum size each time I add/remove Tiles in ViewModel I calculate the total minimum size based on number of items and update my viewmodel property which is bound to RadTileView MinHeight and MinWidth properties. 

Everything is working fine but I am a little stuck in one area. As my RadTileView's MinWidth and MinHeight are bound to ViewModel when user Maximize one of the tiles if there are too many tiles the maximized Tile is way too large. What I want is a workaround so when a single Tile is maximized I reset my ViewModel's MinWidth and MinHeight to a reasonable size to make sure maximized tile look usable. 

I've tried hooking into event TilesStateChanged or TileStateChanged but due to binding I can't enumerate the RadtileViewItems and take appropriate action. 

Any suggestion will be welcome. 

Qaiser.

3 Answers, 1 is accepted

Sort by
0
Qaiser
Top achievements
Rank 1
answered on 23 Jul 2010, 11:18 PM

I seem to find a workaround(a bad one I guess). I have hooked in to TilesStateChanged in view's code behind and check if maximizedItem is null or not. If null I assume no tile is maximized so I calculate my TileViews minWidht/minHeight and otherwise I set them to a reasonable hardcoded value.

Also there seems to be a problem with TileView, if I change MinWidth/MinHeight on TileStateChanged event the TileView doesn't render tiles properly (they seem to overlap each other). To avoid that I start a timer and with half a second delay I run my code to set minwidth/minheight code.

I appreciate if someone can suggest a better solution.

Regards, 

Qaiser.

 

0
Kiril Stanoev
Telerik team
answered on 28 Jul 2010, 02:10 PM
Hi Qaiser,

In your first post you said that you cannot enumerate through the TileViewItems since your TileView is data-bound. Actually, if you subscribe to the TilesStateChanged you can enumerate the TileViewItems in the following manner:

for(int i = 0; i < this.tileView1.Items.Count; i++)
{
    // get the TileViewItem container
    RadTileViewItem tileViewItem = this.tileView1.ItemContainerGenerator.ContainerFromIndex(i) as RadTileViewItem;
    // apply additional logic to the container
}

As for your other issue:

if I change MinWidth/MinHeight on TileStateChanged event the TileView doesn't render tiles properly (they seem to overlap each other).

Try calling RadTileView's public method UpdateItemsSizeAndPosition() after you have set the MinWidth and MinHeight properties. See if it will help.

If nothing I've said does not help, could you please send us a project reproducing the issues. This way we will be better able to assist you.

Sincerely yours,
Kiril Stanoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Qaiser
Top achievements
Rank 1
answered on 29 Jul 2010, 10:46 AM
Thanks Kiril,

Both methods work. I've chosen first solution as it better suits my situation.

Regards,

Qaiser.
Tags
TileView
Asked by
Qaiser
Top achievements
Rank 1
Answers by
Qaiser
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Share this question
or