Anyone can give me some direction on how can I make the tile panel/container allow for variable height tiles? Ideally I would like to have variable heights and widths as show in the sample WPF app from here: http://blogs.infragistics.com/blogs/jason_beres/archive/2009/05/13/windows-azure-healthcare-mvvm-wpf-ado-net-data-services.aspx
However, I would be happy with having fixed width/columns (say two columns of equal width) but I really need to be able to have variable height; that is, two tiles in the same column can have different heights.
Thanks!
AP
2. Custom TilePanelWe need to arrange a tile in a rectangle that has different height and position (according the height and vertical offset factors).public class MyTilePanel : TilePanel{ private bool _hasMaximized; protected override Size MeasureOverride(Size availableSize) { this._hasMaximized = false; foreach (TilePane tile in this.Children) { if (tile.TileState != TileState.Normal) { this._hasMaximized = true; break; } } return base.MeasureOverride(availableSize); } protected override void ArrangeChild(UIElement element, Rect finalRect, bool useAnimation) { if (!this._hasMaximized) { MyTilePane tile = element as MyTilePane; if (tile != null) { finalRect.Y += tile.VerticalOffsetFactor * finalRect.Height; finalRect.Height *= tile.HeightFactor; } } base.ArrangeChild(element, finalRect, useAnimation); }}
1. Custom TilePaneWe need properties that control the height and position of a TilePane relative to the tile dimensionsThe HeightFactor is used to calculate a tile height relative to the uniform cell (normal size)The VerticallOffsetFactor is used to position a tile relative to the normal position. public class MyTilePane : TilePane{ public double HeightFactor { get; set; } public double VerticalOffsetFactor { get; set; } protected override Size MeasureOverride(Size availableSize) { if (!double.IsInfinity(availableSize.Height)) { // The availableSize is a uniform cell size availableSize.Height *= this.HeightFactor; } Size sz = base.MeasureOverride(availableSize); return sz; }}
Thanks Marin,
I thought the solution would be along that path. I tried several things myself with TilePanel but I was unable to come up with anything close to what we need. We are currently evaluating the Silverlight toolkit for our product, and being able to have the variable height tiles is a must.
Looking forward to your sample code, I am sure it will be of great help!
OK, It is not so simple and the solution has some limitations. In general you have to:1. To create a custom TilePane class2. To create a custom TilePanel class3. To edit a XamWebControl template and to replace TilePanel with the new panel4. To handle drag and drop operationsI will create several posts with sample code to help you.Regards,Marin
Exactly like that...
Any help would be appreciated.
Thanks.