Miscellaneous tiles in a Windows application

I know that I can use ListView and GridView to create Tiles / Items of whatever size I want, but how can I create tiles of different sizes for use in my application? This is required to work with ListView or GridView.

I've tried so many things, but I just don't know how. Any help would be much appreciated.

In case I haven't described what I am trying to achieve correctly, here is a photo:

enter image description here

+3


source to share


2 answers


The easy way is to create a new class that inherits from the GridView and override the PrepareContainerForItemOverride method. In which you can set the column and column "Rosean" element "Children" based on model data. Consider that your model class contains Spanning information.

public class VariableGrid : GridView
{
    protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
    {
        ITileItem tile = item as ITileItem;
        if (tile != null)
        {
            GridViewItem griditem = element as GridViewItem;
            if (griditem != null)
            {
                VariableSizedWrapGrid.SetColumnSpan(griditem, tile.ColumnSpan);
                VariableSizedWrapGrid.SetRowSpan(griditem, tile.RowSpan);
            }
        }
        base.PrepareContainerForItemOverride(element, item);
    }
}

      



More information: http://wpfplayground.blogspot.in/2013/03/different-sized-tile-items-in-winrt.html

+2


source


You need to set ItemsPanel

/ of ItemsPanelTemplate

your list to VariableSizedWrapGrid

and set Grid.RowSpan

/ of ColumnSpan

your list items to the values you want . I believe you can do this in a ItemContainerStyle

list control, which is best checked out by right-clicking the control in VS XAML Design View or Blend and choosing Edit Additional Templates / Edit Generated Item Container.



+1


source







All Articles