void ViewCellTap(ViewCell m, EventArgs eventArgs) { Post post = (Post)m.BindingContext; HideAllButtons(post); lstView.SelectedItem = null; m.ForceUpdateSize(); }
private void ShowDescriptionCommandExecute(ViewCell viewCell) { //fruiteModel.IsDescriptionVisible = !fruiteModel.IsDescriptionVisible; ViewCell cell = (viewCell as ViewCell); Fruite vm = cell.BindingContext as Fruite; vm.IsDescriptionVisible = !vm.IsDescriptionVisible; cell.ForceUpdateSize(); }
private void SelectedPlayer_Tapped(object sender, EventArgs e) { if (_selectedPlayer != null) { _selectedPlayer.IsSelected = (e as TappedEventArgs).Parameter as PlayerOfMatch == _selectedPlayer; } _selectedPlayer = (e as TappedEventArgs).Parameter as PlayerOfMatch; _selectedPlayer.IsSelected = true; var view = sender as View; ViewCell parentViewCell = view.Parent as ViewCell; parentViewCell.ForceUpdateSize(); }
public async Task ForceUpdateSizeCallsAreRateLimited() { var lv = new ListView { HasUnevenRows = true }; var cell = new ViewCell { Parent = lv }; int numberOfCalls = 0; cell.ForceUpdateSizeRequested += (object sender, System.EventArgs e) => { numberOfCalls++; }; cell.ForceUpdateSize(); cell.ForceUpdateSize(); cell.ForceUpdateSize(); cell.ForceUpdateSize(); await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(150)); Assert.AreEqual(1, numberOfCalls); }
private void ToggleFrameVisibility() { frame.IsVisible = !frame.IsVisible; if (_parentViewCell == null) { _parentViewCell = getParentViewCell(); } if (_parentViewCell != null) { _parentViewCell.ForceUpdateSize(); } }
private void TaxonEditor_Focused(object sender, FocusEventArgs e) { var thisEditor = sender as Editor; ViewCell viewCell = (ViewCell)thisEditor.Parent.Parent.Parent; if (thisEditor.IsFocused) { thisEditor.BackgroundColor = Color.Accent; viewCell.ForceUpdateSize(); } //if (thisEditor.HeightRequest < 90) { // thisEditor.HeightRequest += 100; // viewCell.ForceUpdateSize(); //} }
private void UpdateCell() { UIAtomsApplication.Instance.TriggerOnce(() => { ViewCell cell = Content.GetParentOfType <ViewCell>(); if (cell != null) { this.InvalidateMeasure(); Device.BeginInvokeOnMainThread(() => { cell.ForceUpdateSize(); }); } }); }
public virtual void RedrawIOS(StackLayout stackLayoutWrapper) { ViewCell viewCell = null; if (ParentViewCellLevel == 3) { viewCell = stackLayoutWrapper.Parent.Parent.Parent as ViewCell; } if (ParentViewCellLevel == 2) { viewCell = stackLayoutWrapper.Parent.Parent as ViewCell; } if (viewCell != null) { viewCell.ForceUpdateSize(); } }
public async Task ForceUpdateSizeWillNotBeCalledIfParentIsNotAListViewWithUnevenRows() { var lv = new ListView { HasUnevenRows = false }; var cell = new ViewCell { Parent = lv }; int numberOfCalls = 0; cell.ForceUpdateSizeRequested += (object sender, System.EventArgs e) => { numberOfCalls++; }; cell.ForceUpdateSize(); await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(16)); Assert.AreEqual(0, numberOfCalls); }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { ViewCell vc = item as ViewCell; if (vc != null) { var sr = vc.View.Measure(tv.Frame.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins); if (vc.Height != sr.Request.Height) { vc.ForceUpdateSize(); sr = vc.View.Measure(tv.Frame.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins); vc.Height = sr.Request.Height; } } return(base.GetCell(item, reusableCell, tv)); }
private void ViewCell_Tapped(object sender, EventArgs e) { ViewCell v = sender as ViewCell; v.ForceUpdateSize(); }
protected override void Init() { var grid = new Grid { Padding = 10, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } }, RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition{ Height = new GridLength(1, GridUnitType.Auto) } } }; grid.Children.Add(new Label { Text = "I am initially visible." }, 0, 0); Label target = new Label { Text = "Success", AutomationId = "lblSuccess", IsVisible = false, TextColor = Color.Red }; grid.Children.Add(target, 0, 1); var tableView = new TableView { HasUnevenRows = true, Intent = TableIntent.Settings }; ViewCell viewCell = new ViewCell { View = grid }; TableSection item = new TableSection { viewCell, new ImageCell { ImageSource = "cover1.jpg" } }; tableView.Root.Add(item); var button = new Button { Text = "Click me", AutomationId = "btnClick", Command = new Command(() => { target.IsVisible = true; viewCell.ForceUpdateSize(); }) }; var label = new Label { Text = "Tap the button to expand the cell. If the cell does not expand and the red text is on top of the image, this test has failed." }; Content = new StackLayout { Children = { label, button, tableView }, Margin = 20 }; }
public async void ForceUpdateSizeWillNotBeCalledIfParentIsNotAListViewWithUnevenRows () { var lv = new ListView { HasUnevenRows = false }; var cell = new ViewCell { Parent = lv }; int numberOfCalls = 0; ((ICellController)cell).ForceUpdateSizeRequested += (object sender, System.EventArgs e) => { numberOfCalls++; }; cell.ForceUpdateSize (); await System.Threading.Tasks.Task.Delay (TimeSpan.FromMilliseconds (16)); Assert.AreEqual (0, numberOfCalls); }
public async void ForceUpdateSizeCallsAreRateLimited() { var lv = new ListView { HasUnevenRows = true }; var cell = new ViewCell { Parent = lv }; int numberOfCalls = 0; ((ICellController)cell).ForceUpdateSizeRequested += (object sender, System.EventArgs e) => { numberOfCalls++; }; cell.ForceUpdateSize (); cell.ForceUpdateSize (); cell.ForceUpdateSize (); cell.ForceUpdateSize (); await System.Threading.Tasks.Task.Delay (TimeSpan.FromMilliseconds (150)); Assert.AreEqual (1, numberOfCalls); }
public YoutubeViewPage() { new FontButton(this); Title = "Youtube"; var youtubeViewModel = new YoutubeViewModel(); BindingContext = youtubeViewModel; /*var label = new Label * { * Text = "Youtube", * TextColor = Color.Gray, * FontSize = 24 * };*/ var dataTemplate = new DataTemplate(() => { var channelTitleLabel = new Label { TextColor = Color.Maroon, FontSize = Device.GetNamedSize(FontButton.GetTextSize(1), typeof(Label)) }; var titleLabel = new Label { TextColor = Color.Black, FontSize = Device.GetNamedSize(FontButton.GetTextSize(0), typeof(Label)) }; var descriptionLabel = new Label { TextColor = Color.Gray, FontSize = Device.GetNamedSize(FontButton.GetTextSize(-1), typeof(Label)) }; /*var viewCountLabel = new Label * { * TextColor = Color.FromHex("#0D47A1"), * FontSize = 14 * }; * var likeCountLabel = new Label * { * TextColor = Color.FromHex("#2196F3"), * FontSize = 14 * }; * var dislikeCountLabel = new Label * { * TextColor = Color.FromHex("#0D47A1"), * FontSize = 14 * }; * var favoriteCountLabel = new Label * { * TextColor = Color.FromHex("#2196F3"), * FontSize = 14 * }; * var commentCountLabel = new Label * { * TextColor = Color.FromHex("#0D47A1"), * FontSize = 14 * };*/ var mediaImage = new Image { HeightRequest = GetImageHeight(FontButton.GetTextSize(0)) }; /*MessagingCenter.Subscribe<Application>(this, "Hi", (sender) => { * * channelTitleLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(1), typeof(Label)); * * titleLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(0), typeof(Label)); * * descriptionLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(-1), typeof(Label)); * * mediaImage.HeightRequest = GetImageHeight(FontButton.GetTextSize(0)); * * });*/ channelTitleLabel.SetBinding(Label.TextProperty, new Binding("ChannelTitle")); titleLabel.SetBinding(Label.TextProperty, new Binding("Title")); descriptionLabel.SetBinding(Label.TextProperty, new Binding("Description")); mediaImage.SetBinding(Image.SourceProperty, new Binding("HighThumbnailUrl")); /*viewCountLabel.SetBinding(Label.TextProperty, new Binding("ViewCount", BindingMode.Default, null, null, "{0:n0} views")); * likeCountLabel.SetBinding(Label.TextProperty, new Binding("LikeCount", BindingMode.Default, null, null, "{0:n0} likes")); * dislikeCountLabel.SetBinding(Label.TextProperty, new Binding("DislikeCount", BindingMode.Default, null, null, "{0:n0} dislike")); * commentCountLabel.SetBinding(Label.TextProperty, new Binding("CommentCount", BindingMode.Default, null, null, "{0:n0} comments")); * favoriteCountLabel.SetBinding(Label.TextProperty, new Binding("FavoriteCount", BindingMode.Default, null, null, "{0:n0} favorite"));*/ var viewCell = new ViewCell { View = new StackLayout { BackgroundColor = Color.FromHex("#e6e6e6"), Children = { new Frame { BackgroundColor = Color.FromHex("#FFFFFF"), CornerRadius = 2, HasShadow = false, Margin = new Thickness(10, 5, 10, 5), Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Horizontal, //Padding = new Thickness(0, 0, 0, 20), Children = { //channelTitleLabel, /*new StackLayout * { * Orientation = StackOrientation.Horizontal, * Children = * { * viewCountLabel, * likeCountLabel, * dislikeCountLabel, * } * }, * new StackLayout * { * Orientation = StackOrientation.Horizontal, * TranslationY = -7, * Children = * { * favoriteCountLabel, * commentCountLabel * } * },*/ mediaImage, new StackLayout { Padding = new Thickness(10, 0, 0, 0), VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Vertical, Children = { titleLabel, descriptionLabel } } } } } } } }; MessagingCenter.Subscribe <Application>(this, "Hi", (sender) => { channelTitleLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(1), typeof(Label)); titleLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(0), typeof(Label)); descriptionLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(-1), typeof(Label)); mediaImage.HeightRequest = GetImageHeight(FontButton.GetTextSize(0)); viewCell.ForceUpdateSize(); }); return(viewCell); }); var listView = new ListView { HasUnevenRows = true }; listView.SetBinding(ListView.ItemsSourceProperty, "YoutubeItems"); listView.ItemTemplate = dataTemplate; listView.ItemTapped += ListViewOnItemTapped; //listView.SeparatorColor = Color.Gray; listView.SeparatorVisibility = SeparatorVisibility.None; listView.BackgroundColor = Color.FromHex("#e6e6e6"); Content = new StackLayout { Children = { //label, listView } }; }
//public ObservableCollection<Data> AccountItems = new ObservableCollection<Data>(); public News() { new FontButton(this); /* * FacebookViewModel fbItems = new FacebookViewModel(); * BindingContext = fbItems; * InitializeComponent(); * * var itemsListView = new ListView(); * itemsListView.ItemsSource = fbItems; * Content = itemsListView; * * * /* * ButtonGetItems.Clicked += async (sender, e) => * { * ButtonGetItems.IsEnabled = false; * GetAccountItemsAsync(); * ButtonGetItems.IsEnabled = true; * };*//* * } * } * } */ var facebookViewModel = new FacebookViewModel(); BindingContext = facebookViewModel; var dataTemplate = new DataTemplate(() => { var messageLabel = new Label { TextColor = Color.Black, FontSize = Device.GetNamedSize(FontButton.GetTextSize(0), typeof(Label)) }; var created_timeLabel = new Label { TextColor = Color.Gray, FontSize = Device.GetNamedSize(FontButton.GetTextSize(0), typeof(Label)) }; var fbMediaImage = new Image { HeightRequest = GetImageHeight(FontButton.GetTextSize(0)), WidthRequest = GetImageHeight(FontButton.GetTextSize(0)) }; /* * var channelTitleLabel = new Label * { * TextColor = Color.Maroon, * FontSize = 22 * * }; * var titleLabel = new Label * { * TextColor = Color.Black, * FontSize = 16 * }; * var descriptionLabel = new Label * { * TextColor = Color.Gray, * FontSize = 14 * };*/ messageLabel.SetBinding(Label.TextProperty, new Binding("Message")); created_timeLabel.SetBinding(Label.TextProperty, new Binding("Created_Time")); fbMediaImage.SetBinding(Image.SourceProperty, new Binding("Picture")); var viewCell = new ViewCell { View = new StackLayout { BackgroundColor = Color.FromHex("#e6e6e6"), Children = { new Frame { BackgroundColor = Color.FromHex("#FFFFFF"), CornerRadius = 2, HasShadow = false, Margin = new Thickness(10, 5, 10, 5), Padding = new Thickness(20, 8, 20, 8), Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Horizontal, //Padding = new Thickness(0, 10, 0, 10), Children = { fbMediaImage, new StackLayout { Padding = new Thickness(10, 0, 0, 0), VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Vertical, Children = { messageLabel, new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, Children = { created_timeLabel, } } } } } } } } } }; MessagingCenter.Subscribe <Application>(this, "Hi", (sender) => { messageLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(0), typeof(Label)); created_timeLabel.FontSize = Device.GetNamedSize(FontButton.GetTextSize(0), typeof(Label)); fbMediaImage.HeightRequest = GetImageHeight(FontButton.GetTextSize(0)); fbMediaImage.WidthRequest = GetImageHeight(FontButton.GetTextSize(0)); viewCell.ForceUpdateSize(); }); return(viewCell); }); var listView = new ListView { HasUnevenRows = true }; listView.SetBinding(ListView.ItemsSourceProperty, new Binding("FacebookItems")); listView.ItemTemplate = dataTemplate; //listView.ItemTapped += ListViewOnItemTapped; //listView.SeparatorColor = Color.Gray; listView.SeparatorVisibility = SeparatorVisibility.None; listView.BackgroundColor = Color.FromHex("#e6e6e6"); Content = new StackLayout { //Padding = new Thickness(5, 10), Children = { //label, listView } }; }