public async void Refrash() { LibraryItem[] searchResult = infoFromNavPage.Item2.ToArray(); if (searchResult.Length == 0) { MessageDialog message = new MessageDialog("THERE IS NO ITEMS THAT MATCH YOUR SEARCH", "EROR!"); await message.ShowAsync(); Frame.Navigate(typeof(ActionsPage), system); } int numOfSearchResult = searchResult.Length; grid.Width = 800; int gridSize = 200; int maxInColoumn = 4; if (searchResult.Length <= 4) { gridSize = 400; maxInColoumn = 2; } int gridHeight = numOfSearchResult / maxInColoumn + 1; gridHeight *= gridSize; grid.Height = gridHeight; for (int i = 0; i < gridHeight / gridSize; i++) { RowDefinition rowDefinition = new RowDefinition(); rowDefinition.Height = new GridLength(gridSize); grid.RowDefinitions.Add(rowDefinition); } for (int i = 0; i < maxInColoumn; i++) { ColumnDefinition columnDefinition = new ColumnDefinition(); columnDefinition.Width = new GridLength(gridSize); grid.ColumnDefinitions.Add(columnDefinition); } int columnCounter = 0; int rowCounter = 0; gridSize = gridSize / 10 * 9; for (int i = 0; i < numOfSearchResult; i++) { ItemInGrid item = new ItemInGrid(searchResult[i], grid, columnCounter, rowCounter, gridSize); item.textBlockHover += Item_textBlockHover; item.textBlockHoverEnds += Item_textBlockHoverEnds; item.textBlockTaped += Item_textBlockTaped; columnCounter++; if (columnCounter == maxInColoumn) { columnCounter = 0; rowCounter++; } } }
public async void GridGenerateor <T>(T[] array) where T : IknowDateDeadLine { if (array.Length == 0) { MessageDialog message = new MessageDialog("THERE IS NO ITEMS THAT MATCH YOUR SEARCH", "EROR!"); await message.ShowAsync(); Frame.Navigate(typeof(ActionsPage), system); } grid.Width = 800; grid.Height = array.Length * 200; for (int i = 0; i < array.Length; i++) { RowDefinition rowDefinition = new RowDefinition(); rowDefinition.Height = new GridLength(200); grid.RowDefinitions.Add(rowDefinition); ItemInGrid <T> item = new ItemInGrid <T>(array[i], grid, i, infoFromNavPage.Item2); item.textBlockTaped += Item_textBlockTaped; } }