private void UpdateItem(CellBase cell) { cell.ButtonPressEvent += (sender, args) => { var gtkCell = sender as CellBase; if (gtkCell != null && gtkCell.Cell != null) { SelectedItem = gtkCell.Item; MarkCellAsSelected(gtkCell); OnItemTapped?.Invoke(this, new ItemTappedEventArgs(SelectedItem)); } }; cell.VisibleWindow = false; _list.PackStart(cell, false, false, 0); cell.ShowAll(); var separator = new ListViewSeparator(); _separators.Add(separator); _list.PackStart(separator, false, false, 0); separator.ShowAll(); }
internal void InvokeItemTappedEvent(object sender, object item) { var args = new ItemTappedEventArgs(item); OnItemTapped?.Invoke(this, args); ItemTappedCommand?.Execute(item); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { tableView.DeselectRow(indexPath, true); OnItemTapped?.Invoke(this, ModelAt(indexPath)); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { OnItemTapped?.Invoke(displayedItems[indexPath.Section][indexPath.Row]); }
void RefreshSource(TableRoot source) { // Clear _cells.Clear(); foreach (var child in _root.AllChildren) { _root.RemoveFromContainer((Widget)child); } // Add Title if (!string.IsNullOrEmpty(source.Title)) { var titleSpan = new Span() { FontSize = 16, Text = source.Title ?? string.Empty }; Gtk.Label title = new Gtk.Label(); title.SetAlignment(0, 0); title.SetTextFromSpan(titleSpan); _root.PackStart(title, false, false, 0); } // Add Table Section for (int i = 0; i < source.Count; i++) { if (source[i] is TableSection tableSection) { var tableSectionSpan = new Span() { FontSize = 12, Text = tableSection.Title ?? string.Empty, TextColor = tableSection.TextColor }; // Table Section Title Gtk.Label sectionTitle = new Gtk.Label(); sectionTitle.SetAlignment(0, 0); sectionTitle.SetTextFromSpan(tableSectionSpan); _root.PackStart(sectionTitle, false, false, 0); // Table Section Separator EventBox separator = new EventBox { HeightRequest = 1 }; separator.ModifyBg(StateType.Normal, Color.Black.ToGtkColor()); _root.PackStart(separator, false, false, 0); // Cells _cells.Clear(); for (int j = 0; j < tableSection.Count; j++) { var cell = tableSection[j]; var renderer = (Cells.CellRenderer)Internals.Registrar.Registered.GetHandlerForObject <IRegisterable>(cell); var nativeCell = renderer.GetCell(cell, null, null); if (nativeCell != null) { nativeCell.ButtonPressEvent += (sender, args) => { if (sender is CellBase gtkCell && gtkCell.Cell != null) { var selectedCell = gtkCell.Cell; OnItemTapped?.Invoke(this, new ItemTappedEventArgs(selectedCell)); } }; _cells.Add(nativeCell); } } foreach (var cell in _cells) { _root.PackStart(cell, false, false, 0); } } // Refresh _root.ShowAll(); } }