public iOSListViewWithCellPageCS() { var personDataTemplate = new DataTemplate(() => { var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.7, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.3, GridUnitType.Star) }); var nameLabel = new Label(); var ageLabel = new Label { HorizontalOptions = LayoutOptions.End }; nameLabel.SetBinding(Label.TextProperty, "Name"); ageLabel.SetBinding(Label.TextProperty, "Age"); grid.Children.Add(nameLabel); grid.Children.Add(ageLabel, 1, 0); return(new ViewCell { View = grid }); }); var groupHeaderTemplate = new DataTemplate(() => { var label = new Label { Margin = new Thickness(10, 10), FontAttributes = FontAttributes.Bold }; label.SetBinding(Label.TextProperty, "Key"); var viewCell = new ViewCell { View = label }; viewCell.On <iOS>().SetDefaultBackgroundColor(Color.Teal); return(viewCell); }); var listView = new Xamarin.Forms.ListView { IsGroupingEnabled = true, ItemTemplate = personDataTemplate, GroupHeaderTemplate = groupHeaderTemplate }; listView.SetBinding(ItemsView <Xamarin.Forms.Cell> .ItemsSourceProperty, "GroupedEmployees"); listView.On <iOS>() .SetSeparatorStyle(SeparatorStyle.FullWidth) .SetRowAnimationsEnabled(false) .SetGroupHeaderStyle(GroupHeaderStyle.Grouped); Title = "ListView/Cell Platform-Specifics"; Content = new StackLayout { Margin = new Thickness(20), Children = { listView } }; BindingContext = new ListViewViewModel(20); }
public DragListAdapter(AWidget.ListView listView, XListView element) { this.listView = listView; // NOTE: careful, the listAdapter might not always be an IWrapperListAdapter this.listAdapter = (listView.Adapter as IWrapperListAdapter)?.WrappedAdapter; this.element = element; }
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } DateTime start = DateTime.Now; ListView listView = (ListView)sender; Faction faction = (Faction)listView.SelectedItem; Team equipe = new Team(); equipe.Id = Guid.NewGuid().ToString(); equipe.Name = faction.Name; equipe.Faction = faction; equipe.Members = new List <Member>(); equipe.Position = KTContext.Db.Teams .Select(a => a.Position) .DefaultIfEmpty(0) .Max() + 1; KTContext.Db.Entry(equipe).State = EntityState.Added; await KTContext.Db.SaveChangesAsync(); Page page = new EquipePage(equipe.Id); var _ = Navigation.PopModalAsync(); await Application.Current.MainPage.Navigation.PushAsync(page); //Deselect Item ((ListView)sender).SelectedItem = null; }
async void OnListViewItemSelected(object sender, EventArgs e) { Xamarin.Forms.ListView listView1 = (Xamarin.Forms.ListView)sender; Models.MaterialDetail detail_select = (Models.MaterialDetail)listView1.SelectedItem; Utils utils = new Utils(); Models.MaterialHeader header_select = await headerfirebaseHelper.GetMaterial(new Guid(detail_select.HeaderID)); //header_select.ProductID if (this.materialHeader_id != header_select.ID) { ProductFirebaseHelper productbaseHelper = new ProductFirebaseHelper(); Models.Product product_select = await productbaseHelper.GetProduct(new Guid(header_select.ProductID)); await headerfirebaseHelper.AddMaterialHeader(utils.convertObject(product_select.Name), utils.convertObject(product_select.NameEn), utils.convertObject(product_select.ID)); await Navigation.PushAsync(new MaterialFoodDetail(utils.convertObject(product_select.ID))); } else { ProductFirebaseHelper productbaseHelper = new ProductFirebaseHelper(); Models.Product product_select = await productbaseHelper.GetProduct(new Guid(header_select.ProductID)); await Navigation.PushAsync(new MaterialFoodDetail(header_select.ID, "Update")); } }
public MainViewMaster() { InitializeComponent(); BindingContext = new MainViewMasterViewModel(); ListView = MenuItemsListView; }
/// <summary> /// Indexs the path at point. /// </summary> /// <returns>The path at point.</returns> /// <param name="listView">List view.</param> /// <param name="p">P.</param> public Tuple <int, int> IndexPathAtPoint(Xamarin.Forms.ListView listView, Xamarin.Forms.Point p) { var renderer = Renderer(listView); var point = new CoreGraphics.CGPoint(p.X * Display.Scale, p.Y * Display.Scale); //System.Diagnostics.Debug.WriteLine("size=["+renderer.Control.Frame.Size+"]"); //System.Diagnostics.Debug.WriteLine("point=["+point+"]"); var visibleCells = renderer.Control.VisibleCells; var visibleCellIndexPaths = renderer.Control.IndexPathsForVisibleRows; var scroll = renderer.Control.ContentOffset; //System.Diagnostics.Debug.WriteLine("Scroll=["+scroll+"]"); foreach (var ip in visibleCellIndexPaths) { var cell = renderer.Control.CellAt(ip); var frame = cell.Frame; var frameX = cell.ConvertRectToView(frame, renderer.Control); var frameZ = new CoreGraphics.CGRect(frameX.X - scroll.X * Display.Scale, frameX.Y - scroll.Y * Display.Scale, frameX.Width * Display.Scale, frameX.Height * Display.Scale); //System.Diagnostics.Debug.WriteLine("ip=["+ip+"] frame=[" + frameZ + "]"); if (frameZ.Contains(point)) { return(new Tuple <int, int>(ip.Section, ip.Row)); } } return(null); //System.Diagnostics.Debug.WriteLine(""); //var indexPath = renderer.Control.IndexPathForRowAtPoint(point); //return new Tuple<int, int>(indexPath.Section, indexPath.Row); }
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } ListView listView = (ListView)sender; Specialist specialite = (Specialist)listView.SelectedItem; Member membre = KTContext.Db.Members.Find(membreId); if (specialite.NameFr == "Aucune") { membre.SpecialistId = null; membre.Specialist = null; } else { membre.SpecialistId = specialite.Id; } KTContext.Db.Entry(membre).State = EntityState.Modified; await KTContext.Db.SaveChangesAsync(); await Application.Current.MainPage.Navigation.PopAsync(); //Deselect Item ((ListView)sender).SelectedItem = null; }
public ListViewInStackLayout() { InitializeComponent(); var listView = new Xamarin.Forms.ListView { RowHeight = 40 }; listView.ItemsSource = new string[] { "Buy pears", "Buy oranges", "Buy mangos", "Buy apples", "Buy bananas" }; var backButton = new Button(); backButton.Text = "返回"; backButton.Clicked += ((sender, e) => { Navigation.PopModalAsync(); }); Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Children = { listView, backButton } }; }
public CREACategoriaEmpresaPage() { StackLayout PaginaPrincipal = new StackLayout { HorizontalOptions = LayoutOptions.Center }; ListViewCategoria = new Xamarin.Forms.ListView(); ListViewCategoria.ItemsSource = App.ListCategoriaEmp; ListViewCategoria.ItemTemplate = new DataTemplate(typeof(ViewCellCategoriasPage)); ListViewCategoria.ItemTapped += ListViewCategoria_ItemTapped; ListViewCategoria.ItemSelected += ListViewCategoria_ItemSelected; ListViewCategoria.RowHeight = 80; ListViewCategoria.IsPullToRefreshEnabled = true; ListViewCategoria.Refreshing += ListViewCategoria_Refreshing; searchBar = new SearchBar { Placeholder = "Palabras Clave", TextColor = Color.Black, BackgroundColor = Color.White }; searchBar.SearchButtonPressed += SearchBar_SearchButtonPressed; PaginaPrincipal.Children.Add(searchBar); PaginaPrincipal.Children.Add(ListViewCategoria); Content = PaginaPrincipal; }
public DragListAdapter(Android.Widget.ListView listView, Xamarin.Forms.ListView element) { _listView = listView; // NOTE: careful, the listAdapter might not always be an IWrapperListAdapter _listAdapter = ((IWrapperListAdapter)_listView.Adapter).WrappedAdapter; _element = element; }
public iOSPanGestureRecognizerPageCS() { Xamarin.Forms.Application.Current.On <iOS>().SetPanGestureRecognizerShouldRecognizeSimultaneously(true); var messageLabel = new Label { Text = "Scroll the list. If you touch the age Label, this Label will change", FontAttributes = FontAttributes.Bold }; var toggleButton = new Button { Text = "Toggle Simultaneous Gesture Recognition" }; toggleButton.Clicked += (sender, e) => Xamarin.Forms.Application.Current.On <iOS>().SetPanGestureRecognizerShouldRecognizeSimultaneously( !Xamarin.Forms.Application.Current.On <iOS>().GetPanGestureRecognizerShouldRecognizeSimultaneously()); var personDataTemplate = new DataTemplate(() => { var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.7, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.3, GridUnitType.Star) }); var nameLabel = new Label(); nameLabel.SetBinding(Label.TextProperty, "Name"); var ageLabel = new Label { HorizontalOptions = LayoutOptions.End }; ageLabel.SetBinding(Label.TextProperty, "Age"); var panGestureRecognizer = new PanGestureRecognizer(); panGestureRecognizer.PanUpdated += (sender, e) => messageLabel.Text = $"panned x:{e.TotalX} y:{e.TotalY}";; ageLabel.GestureRecognizers.Add(panGestureRecognizer); grid.Children.Add(nameLabel); grid.Children.Add(ageLabel, 1, 0); return(new ViewCell { View = grid }); }); var listView = new Xamarin.Forms.ListView { IsGroupingEnabled = true, ItemTemplate = personDataTemplate }; listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, "GroupedEmployees"); listView.GroupDisplayBinding = new Binding("Key"); Title = "Pan Gesture Recognizer"; Content = new StackLayout { Margin = new Thickness(20), Children = { messageLabel, toggleButton, listView } }; BindingContext = new ListViewViewModel(); }
public MainPageMaster() { InitializeComponent(); On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true); BindingContext = new MainPageMasterViewModel(); ListView = MenuItemsListView; }
private void ListOfRecords_ItemSelected(object sender, SelectedItemChangedEventArgs e) { Xamarin.Forms.ListView view = (Xamarin.Forms.ListView)sender; RecordView record = (RecordView)view.SelectedItem; ListViewRecords.Unfocus(); Navigation.PushModalAsync(new ViewLogModal(record)); }
async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e) { Xamarin.Forms.ListView listView1 = (Xamarin.Forms.ListView)sender; Models.MaterialHeader material_select = (Models.MaterialHeader)listView1.SelectedItem; await Navigation.PushAsync(new MaterialFoodAdmin(material_select.ID)); }
async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e) { Xamarin.Forms.ListView listView1 = (Xamarin.Forms.ListView)sender; Models.User user_select = (Models.User)listView1.SelectedItem; await Navigation.PushAsync(new UserAdmin(user_select.ID)); }
protected override void OnElementChanged(ElementChangedEventArgs <ListView> e) { base.OnElementChanged(e); Control.SetSelector(Resource.Layout.no_selector); listView = e.NewElement; Control.ItemLongClick += new EventHandler <AdapterView.ItemLongClickEventArgs>(ItemLong_OnClick); }
//fill the listview with favorite shoes from trello API private async Task getlists(Xamarin.Forms.ListView lvw) { lvw.ItemsSource = ""; string listId = "5fd4e03623dc8d8494238fd9"; List <TrelloCard> trelloCards = await TrelloRepository.GetTrelloCardAsync(listId); lvw.ItemsSource = await TrelloRepository.GetTrelloCardAsync(listId); }
public MainPageMaster() { InitializeComponent(); On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true); //bool LoggedIn = (App.AuthenticationProvider.AuthClient.Users.Count() > 0) ? true : false; //BindingContext = new MainPageMasterViewModel(LoggedIn); BindingContext = new MainPageMasterViewModel(true); ListView = MenuItemsListView; }
public TemplatedItemsListProxy(ListView listview) { this.listview = listview; templated = ((ITemplatedItemsView <Cell>)listview).TemplatedItems; templated.CollectionChanged += Templated_CollectionChanged; UpdateHeader(); UpdateFooter(); }
public ContactsListPage() { var addContactButton = new ToolbarItem { Text = "+", AutomationId = AutomationIdConstants.AddContactButon }; addContactButton.Clicked += HandleAddContactButtonClicked; ToolbarItems.Add(addContactButton); _contactsListView = new Xamarin.Forms.ListView(ListViewCachingStrategy.RecycleElement) { ItemTemplate = new DataTemplate(typeof(ContactsListTextCell)), IsPullToRefreshEnabled = true, BackgroundColor = Color.Transparent, AutomationId = AutomationIdConstants.ContactsListView }; _contactsListView.ItemSelected += HandleItemSelected; _contactsListView.SetBinding(Xamarin.Forms.ListView.ItemsSourceProperty, nameof(ViewModel.AllContactsList)); _contactsListView.SetBinding(Xamarin.Forms.ListView.RefreshCommandProperty, nameof(ViewModel.RefreshCommand)); _contactsListView.SetBinding(Xamarin.Forms.ListView.IsRefreshingProperty, nameof(ViewModel.IsRefreshing)); var restoreDeletedContactsButton = new Button { Text = " Restore Deleted Contacts ", TextColor = ColorConstants.TextColor, AutomationId = AutomationIdConstants.RestoreDeletedContactsButton, BackgroundColor = new Color(ColorConstants.NavigationBarBackgroundColor.R, ColorConstants.NavigationBarBackgroundColor.G, ColorConstants.NavigationBarBackgroundColor.B, 0.25) }; restoreDeletedContactsButton.Clicked += HandleRestoreDeletedContactsButtonClicked; Title = PageTitleConstants.ContactsListPage; var relativeLayout = new RelativeLayout(); relativeLayout.Children.Add(_contactsListView, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(parent => parent.Width), Constraint.RelativeToParent(parent => parent.Height)); relativeLayout.Children.Add(restoreDeletedContactsButton, Constraint.RelativeToParent(parent => parent.Width / 2 - getRestoreDeletedContactsButtonWidth(parent) / 2), Constraint.RelativeToParent(parent => parent.Height - getRestoreDeletedContactsButtonHeight(parent) - 10)); Content = relativeLayout; On <iOS>().SetUseSafeArea(true); double getRestoreDeletedContactsButtonHeight(RelativeLayout parent) => restoreDeletedContactsButton.Measure(parent.Width, parent.Height).Request.Height; double getRestoreDeletedContactsButtonWidth(RelativeLayout parent) => restoreDeletedContactsButton.Measure(parent.Width, parent.Height).Request.Width; }
async void OnListMaterialDetailItemSelected(object sender, EventArgs e) { Xamarin.Forms.ListView listView1 = (Xamarin.Forms.ListView)sender; Models.MaterialSource source_select = (Models.MaterialSource)listView1.SelectedItem; Utils utils = new Utils(); //await headerfirebaseHelper.AddMaterialHeader(utils.convertObject(product_select.Name), utils.convertObject(product_select.NameEn), utils.convertObject(product_select.ID)); await Navigation.PushAsync(new MaterialFoodDetail(source_select.ID)); }
ListViewRenderer Renderer(Xamarin.Forms.ListView listView) { IVisualElementRenderer visualElementRenderer = Platform.GetRenderer(listView); var listViewRenderer = visualElementRenderer as ListViewRenderer; if (listViewRenderer == null) { throw new MissingMemberException("ListViewRenderer not found for ListView"); } return(listViewRenderer); }
async void OnListViewItemSelected(object sender, EventArgs e) { Xamarin.Forms.ListView listView1 = (Xamarin.Forms.ListView)sender; //Models.MaterialDetail detail = (Models.MaterialDetail)listMatrialView.SelectedItem; this.source_select = (Models.MaterialSource)listMatrialView.SelectedItem; // this.source_select = await sourcefirebaseHelper.GetMaterialSource(detail.MaterialID); //this.source_select = Lbl_UnitDisplay.Text = source_select.UnitName; //Utils utils = new Utils(); }
public AndroidListViewFastScrollPageCS() { var personDataTemplate = new DataTemplate(() => { var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.7, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.3, GridUnitType.Star) }); var nameLabel = new Label(); var ageLabel = new Label { HorizontalOptions = LayoutOptions.End }; nameLabel.SetBinding(Label.TextProperty, "Name"); ageLabel.SetBinding(Label.TextProperty, "Age"); grid.Children.Add(nameLabel); grid.Children.Add(ageLabel, 1, 0); return(new Xamarin.Forms.ViewCell { View = grid }); }); var listView = new Xamarin.Forms.ListView { IsGroupingEnabled = true, ItemTemplate = personDataTemplate }; listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, "GroupedEmployees"); listView.GroupDisplayBinding = new Binding("Key"); listView.On <Android>().SetIsFastScrollEnabled(true); var button = new Xamarin.Forms.Button { Text = "Toggle FastScroll" }; button.Clicked += (sender, e) => { listView.On <Android>().SetIsFastScrollEnabled(!listView.On <Android>().IsFastScrollEnabled()); }; Title = "ListView FastScroll"; Content = new StackLayout { Margin = new Thickness(20), Children = { button, listView } }; BindingContext = new ListViewViewModel(); }
void setup() { contractListView = new Xamarin.Forms.ListView(ListViewCachingStrategy.RecycleElement) { AutomationId = "ContractList", ItemTemplate = new DataTemplate(typeof(WorkflowInstanceViewCell)), IsPullToRefreshEnabled = true, SeparatorVisibility = SeparatorVisibility.None, HasUnevenRows = true, IsGroupingEnabled = false, BackgroundColor = Color.FromHex("E3E3E3") }; contractListView.SetBinding(ListView.ItemsSourceProperty, nameof(ViewModel.ContractInstances), BindingMode.TwoWay); contractListView.SetBinding(ListView.RefreshCommandProperty, nameof(ViewModel.RefreshContractsCommand)); contractListView.SetBinding(ListView.IsRefreshingProperty, nameof(ViewModel.IsBusy), BindingMode.TwoWay); //ToolbarItems.Add(new ToolbarItem("Filter", null, async () => await changePropertiesViewedAsync(), ToolbarItemOrder.Primary)); var relativeLayout = new RelativeLayout(); AddContractButton = new FabButton { Text = "", FontFamily = "FontAwesome", TextColor = Color.White, BackgroundColor = Constants.NavBarBackgroundColor, FontSize = 22, CornerRadius = 35, }; if (Device.RuntimePlatform.Equals(Device.Android)) { AddContractButton.Effects.Add(Effect.Resolve("Xamarin.FontAwesomeEffect")); } relativeLayout.Children.Add(contractListView, xConstraint: Constraint.Constant(0), yConstraint: Constraint.Constant(0), widthConstraint: Constraint.RelativeToParent(p => p.Width), heightConstraint: Constraint.RelativeToParent(p => p.Height)); relativeLayout.Children.Add(AddContractButton, xConstraint: Constraint.RelativeToParent(p => p.Width - 78), // padding is 12 yConstraint: Constraint.RelativeToParent(p => p.Height - 78), // padding is 12 widthConstraint: Constraint.Constant(70), heightConstraint: Constraint.Constant(70)); AddContractButton.SetBinding(IsVisibleProperty, "IsUserInitiator"); RootContent = relativeLayout; }
/// <summary> /// Indexs the paths of visible cells. /// </summary> /// <returns>The paths of visible cells.</returns> /// <param name="listView">List view.</param> public List <Tuple <int, int> > IndexPathsOfVisibleCells(Xamarin.Forms.ListView listView) { var renderer = Renderer(listView); var visibleCellIndexPaths = renderer.Control.IndexPathsForVisibleRows; var results = new List <Tuple <int, int> >(); foreach (var ip in visibleCellIndexPaths) { results.Add(new Tuple <int, int>(ip.Section, ip.Row)); } return(results); }
protected override void OnAttached() { element = Element as Xamarin.Forms.ListView; if (Control is Android.Widget.ListView listView) { _dragListAdapter = new DragListAdapter(listView, element); listView.Adapter = _dragListAdapter; listView.SetOnDragListener(_dragListAdapter); listView.OnItemLongClickListener = _dragListAdapter; } }
/********************************************************************** *********************************************************************/ void CreateTopHalf(Grid grid) { listView = new Xamarin.Forms.ListView { ItemTemplate = new DataTemplate(typeof(BuddySystemViewCell)), RowHeight = 100, BackgroundColor = Color.Transparent, }; buddySystemCells = new ObservableCollection <BuddySystemViewCell>(); listView.ItemsSource = buddySystemCells; grid.Children.Add(listView, 0, 0); AddBuddySystemCell(); //add very first cell }
public ContenidoPage() { StackLayout ContentPrincipal = new StackLayout { }; listViewUsuario = new Xamarin.Forms.ListView(); listViewUsuario.ItemsSource = App.lstUsuarios; listViewUsuario.ItemTemplate = new DataTemplate(typeof(View)); listViewUsuario.RowHeight = 60; listViewUsuario.IsPullToRefreshEnabled = true; listViewUsuario.Refreshing += ListViewUsuario_Refreshing; Content = ContentPrincipal; }
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } ListView listView = (ListView)sender; ModelProfile declinaisonModel = (ModelProfile)listView.SelectedItem; await Member.CreateFrom(EquipeId, declinaisonModel.Id); await Application.Current.MainPage.Navigation.PopAsync(); }
public RecentPage() { try { var cell = new DataTemplate(typeof(RecentListCell)); _recentListView = new ListView() { ItemsSource = GetRecentList(), RowHeight = 65, ItemTemplate = cell }; _recentListView.ItemTapped += async (sender, e) => { if (CrossConnectivity.Current.IsConnected == false) { await DisplayAlert("Error", "Please check internet connectivity.", "OK"); return; } if (this.AcquireTapLock()) { var selectedItem = (Recent) e.Item; var doc = new Document() { RelativePath = selectedItem.RelativePath, CreatedBy = selectedItem.CreatedBy, CreatedDateTime = selectedItem.CreatedDateTime, Ext = selectedItem.Ext, Size=selectedItem.Size, Id = selectedItem.Id, IsFolder = false, ModifiedBy = selectedItem.ModifiedBy, ModifiedDateTime = selectedItem.ModifiedDateTime, Name = selectedItem.Name, LibraryGuid = selectedItem.LibraryGuid }; await Navigation.PushAsync(new ContentPageXaml(doc, "Recent", this.Navigation),true); this.ReleaseTapLock(); ((ListView) sender).SelectedItem = null; } }; var upperPanel = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { _recentListView } }; Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); Content = new Xamarin.Forms.ScrollView { Content = upperPanel }; } catch (Exception ex) { DisplayAlert("Error", "An exception occurred.", "OK"); } }