private void InitSearchMembersTableView() { TableView.BackgroundView = new SearchNoResultView() { NoResultText = ViewModel.Resources.SearchNoResults }; TableView.RowHeight = DefaultFoundMembersCellHeight; TableView.RegisterNibForCellReuse(FilteredContactViewCell.Nib, FilteredContactViewCell.Key); TableView.TableFooterView = new UIView(); TableView.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.Interactive; TableView.AddGestureRecognizer(new UITapGestureRecognizer(() => View.EndEditing(true)) { CancelsTouchesInView = false }); _tableViewSource = new ObservableTableViewSource <ChatUserViewModel> { DataSource = ViewModel.PaginationViewModel.Items, BindCellDelegate = (cell, viewModel, index) => { if (cell is IBindableViewCell <ChatUserViewModel> memberCell) { memberCell.Bind(viewModel); } }, ReuseId = FilteredContactViewCell.Key }; TableView.Source = _tableViewSource; }
public void ObservableTableViewSource_NewSourceWithCollectionGettingLastItem() { Vm = new TestViewModel { ItemsCollection = new ObservableCollection <TestItem>() }; _tableView = new UITableView(); var source = new ObservableTableViewSource <TestItem> { CreateCellDelegate = CreateCell, BindCellDelegate = BindCell, DataSource = Vm.ItemsCollection, }; _tableView.Source = source; Assert.AreEqual( Vm.ItemsCollection.Count, _tableView.NumberOfRowsInSection(0)); // In unit tests, GetCell only gets called for the first inserted row (no layout pass) Vm.ItemsCollection.Add(new TestItem("One")); var lastCell = _tableView.CellAt(Vm.ItemsCollection.First().RowIndexPath); Assert.AreEqual( Vm.ItemsCollection.Last().Title, lastCell.TextLabel.Text); }
private void InitTableView() { _tableViewSource = new ObservableTableViewSource <ChatUserViewModel> { DataSource = ViewModel.PaginationViewModel.Items, BindCellDelegate = (cell, viewModel, index) => { if (cell is IBindableViewCell <ChatUserViewModel> memberCell) { memberCell.Bind(viewModel); } }, ReuseId = FilteredContactViewCell.Key }; _tableViewHeader = new NewGroupView(new CGRect(0, 0, TableView.Frame.Width, 60)); _tableViewHeader.SetCommand(ViewModel.CreateGroupChatCommand); _tableViewHeader.SetText(ViewModel.LocalizedStrings.NewGroup); TableView.TableHeaderView = _tableViewHeader; TableView.TableFooterView = new UIView(); TableView.RegisterNibForCellReuse(FilteredContactViewCell.Nib, FilteredContactViewCell.Key); TableView.Source = _tableViewSource; TableView.AddGestureRecognizer(new UITapGestureRecognizer((obj) => View.EndEditing(true)) { CancelsTouchesInView = false }); TableView.BackgroundView = new SearchNoResultView() { NoResultText = ViewModel.LocalizedStrings.SearchNoResults }; }
public override void ViewDidLoad() { base.ViewDidLoad(); InitializeComponent(); source = Vm.FoundUsers.GetTableViewSource(CreateUserTableViewCell, BindUserTableViewCell, "UserCell", factory: null); TableView.Source = source; }
public override void ViewDidLoad() { base.ViewDidLoad(); _source = Vm.Items.GetTableViewSource( BindTestTableViewCell, ReuseId, factory: () => new TableViewSourceEx()); TableView.RegisterClassForCellReuse(typeof(TestTableViewCell), new NSString(ReuseId)); _source.GetHeightForHeaderDelegate = () => 50; _source.GetViewForHeaderDelegate = () => { _headerView = new HeaderForTableView(); _bindings.Add( this.SetBinding( () => _source.SelectedItem.Name, () => _headerView.SelectedItemLabel.Text, fallbackValue: "Nothing yet")); _bindings.Add( this.SetBinding( () => Vm.ToggledItems, () => _headerView.ToggledItemsLabel.Text)); return(_headerView); }; TableView.Source = _source; var addButton = new UIBarButtonItem { Title = "Add" }; addButton.SetCommand(Vm.AddCommand); var delButton = new UIBarButtonItem { Title = "Del" }; var selectedItemBinding = this.SetBinding(() => _source.SelectedItem); _bindings.Add(selectedItemBinding); delButton.SetCommand(Vm.DeleteCommand, selectedItemBinding); NavigationItem.RightBarButtonItems = new[] { delButton, addButton, }; }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = EpamStyles.PrimaryColor1; menuSource = ViewModel.Menu.GetTableViewSource <string>( BindCell, null, () => new TableViewSourceEx()); currentItemBinding = this.SetBinding(() => menuSource.SelectedItem, () => ViewModel.SelectedItem, BindingMode.TwoWay); MenuItemTable.Source = menuSource; }
private void InitChatMembersTableView() { TableView.RegisterNibForCellReuse(ChatUserViewCell.Nib, ChatUserViewCell.Key); TableView.RowHeight = 60; TableView.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.Interactive; TableView.TableHeaderView = _chatDetailsHeaderView; _tableViewSource = ViewModel.Contacts.GetTableViewSource((cell, viewModel, index) => { if (cell is IBindableViewCell <ChatUserViewModel> userCell) { userCell.Bind(viewModel); } }, ChatUserViewCell.Key); TableView.Source = _tableViewSource; }
public override void SetupBindings() { try { _bindings.Add(this.SetBinding(() => Vm.SearchLocation, () => LocationText.Text, BindingMode.TwoWay)); _bindings.Add(this.SetBinding(() => Vm.CurrentWeather.Description, () => DescriptionText.Text)); _bindings.Add(this.SetBinding(() => Vm.CurrentWeather.Temp, () => TempText.Text)); IconImage.SetImage(new NSUrl(Vm.CurrentWeather.Icon), UIImage.FromBundle("01d.png")); _source = Vm.Forecasts.GetTableViewSource(BindForecastCell, ReuseId); ForecastsTableView.RegisterClassForCellReuse(typeof(UITableViewCell), new NSString(ReuseId)); ForecastsTableView.Source = _source; } catch (Exception) { } }
public void ObservableTableViewSource_NewSourceWithListCheckingItemCount() { Vm = GetViewModel(); _tableView = new UITableView(); var source = new ObservableTableViewSource <TestItem> { CreateCellDelegate = CreateCell, BindCellDelegate = BindCell, DataSource = Vm.ItemsList, }; _tableView.Source = source; Assert.AreEqual( Vm.ItemsList.Count, _tableView.NumberOfRowsInSection(0)); }
public override void ViewDidLoad() { try { #region Hidden // See https://developer.xamarin.com/guides/android/advanced_topics/linking/#falseflag var falseFlag = false; // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (falseFlag) // ReSharper disable HeuristicUnreachableCode { RefreshButton.Clicked += (s, e) => { }; } // ReSharper restore HeuristicUnreachableCode #endregion _bindings.Add(this.SetBinding( () => Vm.LastLoadedFormatted, () => LastLoadedText.Text)); RefreshButton.SetCommand(Vm.RefreshCommand); _source = Vm.Flowers.GetTableViewSource( BindFlowerCell, ReuseId); FlowersTableView.RegisterClassForCellReuse(typeof(UITableViewCell), new NSString(ReuseId)); FlowersTableView.Source = _source; _source.SelectionChanged += (s, e) => Vm.ShowDetailsCommand.Execute(_source.SelectedItem); base.ViewDidLoad(); } catch (Exception ex) { } }
public override void ViewDidLoad() { base.ViewDidLoad(); Vm.Initialize(); AddTaskButton = new UIBarButtonItem(UIBarButtonSystemItem.Add); this.NavigationItem.SetLeftBarButtonItem(AddTaskButton, false); //note this was needed when deploying to a real iPhone but worked //on the simulator without it. The Argument Exception Event not found clicked was thrown AddTaskButton.Clicked += (sender, e) => { }; AddTaskButton.SetCommand("Clicked", Vm.AddTaskCommand); source = Vm.TodoTasks.GetTableViewSource( CreateTaskCell, BindTaskCell, factory: () => new TaskListObservableTableSource()); TasksTableView.Source = source; }
public CustomViewDelegate(ObservableTableViewSource <ChatSummaryViewModel> source, ChatsListViewModel viewModel) { _sourceRef = WeakReferenceEx.Create(source); _viewModelRef = WeakReferenceEx.Create(viewModel); }
public override void ViewDidLoad() { base.ViewDidLoad(); var nav = (NavigationService)ServiceLocator.Current.GetInstance <INavigationService>(); var useCreateCell = (bool?)nav.GetAndRemoveParameter(this); if (useCreateCell == null || useCreateCell.Value) { _source = Vm.Items.GetTableViewSource( CreateCell, BindUiTableViewCell, factory: () => new TableViewSourceEx()); } else { _source = Vm.Items.GetTableViewSource( BindTestTableViewCell, ReuseId, factory: () => new TableViewSourceEx()); TableView.RegisterClassForCellReuse(typeof(TestTableViewCell), new NSString(ReuseId)); } _source.GetHeightForHeaderDelegate = () => 50; _source.GetViewForHeaderDelegate = () => { _headerView = new HeaderForTableView(); _bindings.Add( this.SetBinding( () => _source.SelectedItem.Title, () => _headerView.SelectedItemLabel.Text, fallbackValue: "Nothing yet")); return(_headerView); }; TableView.Source = _source; var addButton = new UIBarButtonItem { Title = "Add" }; addButton.SetCommand(Vm.AddCommand); var delButton = new UIBarButtonItem { Title = "Del" }; var selectedItemBinding = this.SetBinding(() => _source.SelectedItem); _bindings.Add(selectedItemBinding); delButton.SetCommand(Vm.DeleteCommand, selectedItemBinding); NavigationItem.RightBarButtonItems = new[] { delButton, addButton, }; }