private void BindProjects(List <Tenant> projects) { TB_NDevices_Filtered.Text = projects.Count.ToString(CultureInfo.InvariantCulture); GRD_Projects_List.Children.Clear(); int column = 1; int line = 1; double marginLeft; double marginTop = DefaultMargin; int projectMaxSize = ProjectMaxSize(); SP_Projects_Info_Top.Height = NRows * ItemHeight + (NRows - 2) * DefaultMarginTop - SP_Projects_Info_Top.Margin.Bottom - 100; TB_FilterProjects.Width = (NColumns * ItemWidth) - ((NColumns - 2) * DefaultMargin) + 2; foreach (var project in projects) { if (project != null) { if (column <= NColumns) { marginLeft = (column - 1) * ItemWidth + column * DefaultMargin; column++; } else { marginLeft = DefaultMargin; marginTop = line * ItemHeight + (line + 1) * DefaultMarginTop; column = 2; line++; } UC_Projects_Item project_item = new UC_Projects_Item() { Margin = new Thickness(marginLeft, marginTop, DefaultMargin, 0), ItemWidth = ItemWidth, ItemHeight = ItemHeight, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, BRDColor = new SolidColorBrush(ColorHandler.FromHex(project.FillColor)), BGColor = new SolidColorBrush(ColorHandler.FromHex(project.FillColor)) }; project_item.ItemTapped += Project_item_ItemTapped; project_item.BindData(project, projectMaxSize); GRD_Projects_List.Children.Add(project_item); } } }
private void Project_item_ItemTapped(object sender, RoutedEventArgs e) { UC_Projects_Item selectedItem = sender as UC_Projects_Item; SelectedProject = selectedItem.Project; if (ItemSelected != null) { ItemSelected?.Invoke(sender, null); } Debug.WriteLine("Project_item_ItemTapped"); }