private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { ListViewItem lvi = (args.ItemContainer as ListViewItem); if (lvi != null) { UIElement element = VisualTreeHelper.GetChild(lvi, 0) as UIElement; if (element != null) { element.PointerPressed -= OnPointerPressed; element.PointerReleased -= OnPointerReleased; element.PointerCaptureLost -= OnPointerCaptureLost; element.PointerExited -= OnPointerExited; } } } else if (args.Phase == 0) { ListViewItem lvi = (args.ItemContainer as ListViewItem); if (null != lvi) { UIElement element = VisualTreeHelper.GetChild(lvi, 0) as UIElement; if (null != element) { element.PointerPressed += OnPointerPressed; element.PointerReleased += OnPointerReleased; element.PointerCaptureLost += OnPointerCaptureLost; element.PointerExited += OnPointerExited; } } } }
/// <summary> /// We will visualize the data item in asynchronously in multiple phases for improved panning user experience /// of large lists. In this sample scneario, we will visualize different parts of the data item /// in the following order: /// /// 1) Placeholders (visualized synchronously - Phase 0) /// 2) Labels (visualized asynchronously - Phase 1) /// 3) Values (visualized asynchronously - Phase 2) /// /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void Items_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { TeamsDrillDownItem iv = args.ItemContainer.ContentTemplateRoot as TeamsDrillDownItem; if (args.InRecycleQueue == true) { iv.ClearData(); } else if (args.Phase == 0) { iv.ShowPlaceholder(args.Item as TeamsDrillDownViewModel); // Register for async callback to visualize Title asynchronously args.RegisterUpdateCallback(ContainerContentChangingDelegate); } else if (args.Phase == 1) { iv.ShowLabels(); args.RegisterUpdateCallback(ContainerContentChangingDelegate); } else if (args.Phase == 2) { iv.ShowValues(); args.RegisterUpdateCallback(ContainerContentChangingDelegate); } // For improved performance, set Handled to true since app is visualizing the data item args.Handled = true; }
private static bool PerformNextPhase(ContainerContentChangingEventArgs args) { args.Handled = false; var phaseIndex = (int)args.Phase; var controlChangingState = args.ItemContainer.Tag as ControlChangingState; if (controlChangingState == null) { controlChangingState = new ControlChangingState(); args.ItemContainer.Tag = controlChangingState; } if (phaseIndex == 0) { controlChangingState.Initialise(args); } else { var itemsToShow = controlChangingState.GetControlsInPhase(phaseIndex-1); foreach (var item in itemsToShow) { controlChangingState.ShowItem(args, item); } } if (phaseIndex <= controlChangingState.MaxPhaseIndex+1) { return true; } return false; }
void ItemGridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { //ItemViewer iv = args.ItemContainer.ContentTemplateRoot as ItemViewer; //if (args.InRecycleQueue == true) //{ // iv.ClearData(); //} //else if (args.Phase == 0) //{ // iv.ShowPlaceholder(args.Item as Item); // // Register for async callback to visualize Title asynchronously // args.RegisterUpdateCallback(ContainerContentChangingDelegate); //} //else if (args.Phase == 1) //{ // iv.ShowTitle(); // args.RegisterUpdateCallback(ContainerContentChangingDelegate); //} //else if (args.Phase == 2) //{ // iv.ShowCategory(); // iv.ShowImage(); //} //// For imporved performance, set Handled to true since app is visualizing the data item //args.Handled = true; }
/// <summary> /// We will visualize the data item in asynchronously in multiple phases for improved panning user experience /// of large lists. In this sample scneario, we will visualize different parts of the data item /// in the following order: /// /// 1) Title and placeholder for Image (visualized synchronously - Phase 0) /// 2) Subtilte (visualized asynchronously - Phase 1) /// 3) Image (visualized asynchronously - Phase 2) /// /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void ItemListView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { Scenario2ItemViewer iv = args.ItemContainer.ContentTemplateRoot as Scenario2ItemViewer; if (args.InRecycleQueue == true) { iv.ClearData(); } else if (args.Phase == 0) { iv.ShowTitle(args.Item as Item); // Register for async callback to visualize Title asynchronously args.RegisterUpdateCallback(ContainerContentChangingDelegate); } else if (args.Phase == 1) { iv.ShowSubtitle(); args.RegisterUpdateCallback(ContainerContentChangingDelegate); } else if (args.Phase == 2) { iv.ShowImage(); } // For imporved performance, set Handled to true since app is visualizing the data item args.Handled = true; }
internal bool Phase0Load(ListViewBase sender, ContainerContentChangingEventArgs args) { if (!args.InRecycleQueue) { if (((CommentViewModel)args.Item).IsEditing) { var editContent = (Resources["editingTemplate"] as DataTemplate).LoadContent() as FrameworkElement; editContent.DataContext = ((CommentViewModel)DataContext).ReplyViewModel; contentControl.Content = editContent; contentControl.MinHeight = 0; return false; } else { contentControl.ContentTemplate = null; contentControl.Content = null; var body = ((CommentViewModel)args.Item).Body ?? ""; contentControl.MinHeight = Math.Max(25, body.Length / 2); args.Handled = true; LoadPhase = 1; return true; } } return false; }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var visual = ElementCompositionPreview.GetElementVisual(args.ItemContainer); visual.ImplicitAnimations = args.InRecycleQueue ? null : animations; }
private void ApplyPhaseTwo(ContainerContentChangingEventArgs args) { var templateRoot = args.ItemContainer.ContentTemplateRoot as StackPanel; var hockeyPlayerVM = args.Item as HockeyPlayerViewModel; var image = templateRoot.Children[0] as Image; image.Source = new BitmapImage { UriSource = new Uri(hockeyPlayerVM.Photo), DecodePixelWidth = 50, DecodePixelHeight = 50 }; image.Opacity = 1; }
private void ListView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { CompositionImage image = args.ItemContainer.ContentTemplateRoot.GetFirstDescendantOfType<CompositionImage>(); Thumbnail thumbnail = args.Item as Thumbnail; // Update the image URI image.Source = new Uri(thumbnail.ImageUrl); }
private void messageList_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.ItemContainer.ContentTemplateRoot is MessageControl) { var message = args.ItemContainer.ContentTemplateRoot as MessageControl; message.DataContext = args.Item; message.PhaseLoad(sender, args); } }
/// <summary> /// Enable accessibility on each nav menu item by setting the AutomationProperties.Name on each container /// using the associated Label of each item. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void NavMenuItemContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (!args.InRecycleQueue && args.Item != null && args.Item is NavMenuItem) { args.ItemContainer.SetValue(AutomationProperties.NameProperty, ((NavMenuItem)args.Item).Label); } else { args.ItemContainer.ClearValue(AutomationProperties.NameProperty); } }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { if (_index > _associatedObject.Items.Count - 1) { _index = _associatedObject.Items.Count - 1; } _associatedObject.SelectedIndex = _index; } }
private static void ListViewContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { // We need to leave this as false, otherwise data binding will not work args.Handled = false; bool hasMore = PerformNextPhase(args); if (hasMore) { args.RegisterUpdateCallback(ListViewContainerContentChanging); } }
private void SampleTreeView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var node = args.Item as TreeNode; if (node != null) { var data = node.Data as FileSystemData; if (data != null) { args.ItemContainer.AllowDrop = data.IsFolder; } } }
private void Grid1_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (!args.InRecycleQueue) { FrameworkElement ctr = (FrameworkElement)args.ItemContainer.ContentTemplateRoot; if (ctr != null) { TextBlock t = (TextBlock)ctr.FindName("idx"); t.Text = args.ItemIndex.ToString(); } } }
private void ApplyPhaseOne(ContainerContentChangingEventArgs args) { var templateRoot = args.ItemContainer.ContentTemplateRoot as StackPanel; var hockeyPlayerVM = args.Item as HockeyPlayerViewModel; var numberTextBlock = templateRoot.Children[1] as TextBlock; numberTextBlock.Text = hockeyPlayerVM.Number.ToString(); numberTextBlock.Opacity = 1; var goalsTextBlock = templateRoot.Children[4] as TextBlock; goalsTextBlock.Text = hockeyPlayerVM.Goals.ToString(); goalsTextBlock.Opacity = 1; }
private void gridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var elementVisual = ElementCompositionPreview.GetElementVisual(args.ItemContainer); if (args.InRecycleQueue) { elementVisual.ImplicitAnimations = null; } else { //Add implicit animation to each visual elementVisual.ImplicitAnimations = _elementImplicitAnimation; } }
private void Recommend_OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var view = args.ItemContainer.ContentTemplateRoot as EditorRecommendView; if (view == null) { return; } if (args.InRecycleQueue == true) { view.Clear(); } else { switch (args.Phase) { case 0: view.ShowPlaceHolder(args.Item as EditorRecommend); args.RegisterUpdateCallback(RecommendChanging); break; case 1: view.ShowTitle(); args.RegisterUpdateCallback(RecommendChanging); break; case 2: view.ShowSummary(); args.RegisterUpdateCallback(RecommendChanging); break; case 3: view.ShowVoteCount(); args.RegisterUpdateCallback(RecommendChanging); break; case 4: view.ShowAvatar(); view.RegisteEventHandler(_recommendTitleTapped, _recommendSummaryTapped, _recommendAuthorTapped); break; } args.Handled = true; } }
private async void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var sticker = args.Item as Sticker; if (args.Phase == 0) { var title = content.Children[1] as TextBlock; title.Text = sticker.Emoji; } else if (args.Phase == 1) { } else if (args.Phase == 2) { var photo = content.Children[0] as Image; if (sticker == null || sticker.Thumbnail == null) { return; } var file = sticker.Thumbnail.Photo; if (file.Local.IsDownloadingCompleted) { var temp = await StorageFile.GetFileFromPathAsync(file.Local.Path); var buffer = await FileIO.ReadBufferAsync(temp); photo.Source = WebPImage.DecodeFromBuffer(buffer); } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { photo.Source = null; ViewModel.ProtoService.Send(new DownloadFile(file.Id, 1)); } } if (args.Phase < 2) { args.RegisterUpdateCallback(OnContainerContentChanging); } args.Handled = true; }
private void ServiceList_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.ItemContainer != null) { if (_services == null) { _services = new ObservableCollection <ServiceModel>(); } if (_services.Where(m => m.Code.Equals(((ServiceModel)args.Item).Code)).Count() > 0) { args.ItemContainer.IsSelected = true; } } }
/// <summary> /// Updates the reorder animation to each container, whenever one changes. /// </summary> /// <param name="sender">The sender <see cref="ListViewBase"/> instance.</param> /// <param name="args">The <see cref="ContainerContentChangingEventArgs"/> instance for the current container change.</param> private static void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { PokeUIElementZIndex(args.ItemContainer); } else { Visual visual = ElementCompositionPreview.GetElementVisual(args.ItemContainer); ImplicitAnimationCollection animationCollection = sender.GetValue(ReorderAnimationProperty) as ImplicitAnimationCollection; visual.ImplicitAnimations = animationCollection; } }
private void ButtonListGridViewContentChanged(ListViewBase sender, ContainerContentChangingEventArgs args) { Grid gridOfButton = ((Grid)args.ItemContainer.ContentTemplateRoot); bool isGridInList = _ListOfGrid.FirstOrDefault(p => p == gridOfButton) != null; if (!isGridInList) { _ListOfGrid.Add(gridOfButton); } MainMenuButton buttonClass = ((MainMenuButton)args.Item); gridOfButton.Background = buttonClass.BackgroundColor; }
private void GridView1_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { FrameworkElement source = args.ItemContainer as FrameworkElement; if (args.Item is ColorEntry) { AutomationProperties.SetName(args.ItemContainer, ((ColorEntry)args.Item).name); } else { var i = (KeyValuePair <string, List <ColorEntry> >)args.Item; AutomationProperties.SetName(args.ItemContainer, i.Key); } }
private static void ColorContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var itemContainer = args.ItemContainer as ListViewItem; var itemIndex = sender.IndexFromContainer(itemContainer); if (itemIndex % 2 == 0) { itemContainer.Background = GetColor(sender); } else { itemContainer.Background = null; } }
private void ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { var templateRoot = args.ItemContainer.ContentTemplateRoot as Grid; var image = (Image)templateRoot.FindName("ItemImage"); image.Source = null; } if (args.Phase == 0) { args.RegisterUpdateCallback(ShowImageThumbnail); args.Handled = true; } }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as PassportDocumentCell; var datedFile = args.Item as DatedFile; content.UpdateFile(ViewModel.ProtoService, datedFile); args.Handled = true; }
// Unused, replaced with composition method // This is only get called by ItemDetailsPage.Episodesitem_ContainerContentChanging private async void LegacyLoadImage(ListViewBase sender, ContainerContentChangingEventArgs args) { var img = new BitmapImage { DecodePixelWidth = 180, DecodePixelType = DecodePixelType.Logical, CreateOptions = BitmapCreateOptions.IgnoreImageCache }; Thumbnail.Source = img; if (contentlist.State != Models.MediaList.MediaListState.OFFLINE) { // thumbnail is from online source. var file = await ImageCache.GetFromCacheAsync(contentlist.Thumbnail.AbsoluteUri); img.UriSource = new Uri(file.Path); } else { // thumbnail is from offline source. var file = await StorageFile.GetFileFromPathAsync(contentlist.Thumbnail.LocalPath); var thumbnail = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.VideosView); if (thumbnail != null) { await img.SetSourceAsync(thumbnail); } } DoubleAnimation animation = new DoubleAnimation { From = 0, To = 1, Duration = new Duration(TimeSpan.FromMilliseconds(700)), EasingFunction = new ExponentialEase { Exponent = 7, EasingMode = EasingMode.EaseOut } }; Storyboard ImageOpenedOpacity = new Storyboard(); ImageOpenedOpacity.Children.Add(animation); Storyboard.SetTarget(ImageOpenedOpacity, Thumbnail); Storyboard.SetTargetProperty(ImageOpenedOpacity, "Opacity"); ImageOpenedOpacity.Begin(); }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot; if (content != null) { content.IsHitTestVisible = SelectionMode != ListViewSelectionMode.Multiple; } }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (!args.InRecycleQueue) { var container = args.ItemContainer; var containerVisual = ElementCompositionPreview.GetElementVisual(container); var item = container.GetChildOfType <Border>(); var itemVisual = ElementCompositionPreview.GetElementVisual(item); Expression.SetReferenceParameter("container", containerVisual); itemVisual.StartAnimation("Offset", Expression); } }
private void GridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { Visual elementVisual = ElementCompositionPreview.GetElementVisual(args.ItemContainer); if (args.InRecycleQueue) { elementVisual.ImplicitAnimations = null; } else { EnsureImplicitAnimations(args.ItemContainer); elementVisual.ImplicitAnimations = _implicitAnimations; } }
private void LVContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var elementVisual = ElementCompositionPreview.GetElementVisual(args.ItemContainer); if (args.InRecycleQueue) { elementVisual.ImplicitAnimations = null; } else { //Add implicit animation to each visual elementVisual.ImplicitAnimations = _elementImplicitAnimation; } }
internal void PhaseLoad(ListViewBase sender, ContainerContentChangingEventArgs args) { if (!args.InRecycleQueue) { switch (args.Phase) { case 0: { plainTextControl.Visibility = Windows.UI.Xaml.Visibility.Collapsed; markdownControl.Visibility = Windows.UI.Xaml.Visibility.Collapsed; markdownControl.Markdown = null; args.Handled = true; args.RegisterUpdateCallback(PhaseLoad); break; } case 1: { plainTextControl.Visibility = Windows.UI.Xaml.Visibility.Visible; if (args.Item is MessageActivityViewModel) plainTextControl.Text = ((MessageActivityViewModel)args.Item).Body; args.Handled = true; args.RegisterUpdateCallback(PhaseLoad); break; } case 2: { if (args.Item is MessageActivityViewModel) { var body = ((MessageActivityViewModel)args.Item).Body; args.Handled = true; var markdownBody = SnooStreamViewModel.MarkdownProcessor.Process(body); if (!SnooStreamViewModel.MarkdownProcessor.IsPlainText(markdownBody)) { plainTextControl.Visibility = Windows.UI.Xaml.Visibility.Collapsed; plainTextControl.Text = ""; markdownControl.Visibility = Windows.UI.Xaml.Visibility.Visible; markdownControl.Markdown = markdownBody.MarkdownDom as SnooDom.SnooDom; } } break; } } } else { } }
private void gridviewImages_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { int index = args.ItemIndex; var root = args.ItemContainer.ContentTemplateRoot as UserControl; var item = args.Item as ImportedImage; // Don't run an entrance animation if we're in recycling if (!args.InRecycleQueue) { args.ItemContainer.Loaded += ItemContainer_Loaded; } //args.Handled = true; }
private static void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var elementVisual = ElementCompositionPreview.GetElementVisual(args.ItemContainer); if (args.InRecycleQueue) { elementVisual.ImplicitAnimations = null; } else { var elementImplicitAnimation = sender.GetValue(ReorderAnimationProperty) as ImplicitAnimationCollection; elementVisual.ImplicitAnimations = elementImplicitAnimation; } }
private async void Stickers_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var content = args.ItemContainer.ContentTemplateRoot as Image; if (args.InRecycleQueue) { content.Source = null; return; } var sticker = args.Item as ViewModels.Dialogs.StickerViewModel; if (sticker == null || sticker.Thumbnail == null) { content.Source = null; return; } //if (args.Phase < 2) //{ // content.Source = null; // args.RegisterUpdateCallback(Stickers_ContainerContentChanging); //} //else if (args.Phase == 0) { Debug.WriteLine("Loading sticker " + sticker.StickerData.Id + " for sticker set id " + sticker.SetId); var file = sticker.Thumbnail.Photo; if (file.Local.IsDownloadingCompleted) { var temp = await StorageFile.GetFileFromPathAsync(file.Local.Path); var buffer = await FileIO.ReadBufferAsync(temp); content.Source = WebPImage.DecodeFromBuffer(buffer); } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { DownloadFile(file.Id, sticker); } } else { throw new System.Exception("We should be in phase 0, but we are not."); } args.Handled = true; }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var content = args.ItemContainer.ContentTemplateRoot as Border; var animation = args.Item as Animation; if (args.InRecycleQueue) { if (content.Child is AnimationView recycle) { recycle.Source = null; } return; } var view = content.Child as AnimationView; var file = animation.AnimationValue; if (file == null) { return; } if (file.Local.IsDownloadingCompleted) { view.Source = new LocalVideoSource(file); view.Thumbnail = null; } else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive) { view.Source = null; DownloadFile(file.Id, animation); var thumbnail = animation.Thumbnail?.File; if (thumbnail != null) { if (thumbnail.Local.IsDownloadingCompleted) { view.Thumbnail = new BitmapImage(UriEx.ToLocal(thumbnail.Local.Path)); } else if (thumbnail.Local.CanBeDownloaded && !thumbnail.Local.IsDownloadingActive) { view.Thumbnail = null; DownloadFile(thumbnail.Id, animation); } } } }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var statistics = args.Item as StorageStatisticsByChat; var chat = ViewModel.ProtoService.GetChat(statistics.ChatId); //if (chat == null) //{ // return; //} if (args.Phase == 0) { var title = content.Children[1] as TextBlock; title.Text = chat == null ? "Other Chats" : ViewModel.ProtoService.GetTitle(chat); } else if (args.Phase == 1) { var subtitle = content.Children[2] as TextBlock; subtitle.Text = FileSizeConverter.Convert(statistics.Size, true); } else if (args.Phase == 2) { var photo = content.Children[0] as ProfilePicture; if (chat == null) { photo.Source = null; photo.Visibility = Visibility.Collapsed; } else { photo.SetChat(ViewModel.ProtoService, chat, 36); photo.Visibility = Visibility.Visible; } } if (args.Phase < 2) { args.RegisterUpdateCallback(OnContainerContentChanging); } args.Handled = true; }
private void Activity_OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var view = args.ItemContainer.ContentTemplateRoot as TopicActivityView; if (view == null) { return; } if (args.InRecycleQueue == true) { view.Clear(); } else if (args.Phase == 0) { view.ShowPlaceholder(args.Item as TopicActivity); args.RegisterUpdateCallback(ActivityChanging); } else if (args.Phase == 1) { view.ShowTitle(); args.RegisterUpdateCallback(ActivityChanging); } else if (args.Phase == 2) { view.ShowAnswer1(); args.RegisterUpdateCallback(ActivityChanging); } else if (args.Phase == 3) { view.ShowAnswer2(); args.RegisterUpdateCallback(ActivityChanging); } else if (args.Phase == 4) { view.ShowAnswer3(); args.RegisterUpdateCallback(ActivityChanging); } else if (args.Phase == 5) { view.RegistEventHandler(this.QuestionTapped, this.AnswerTapped); } args.Handled = true; }
private void Collection_OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var view = args.ItemContainer.ContentTemplateRoot as CollectionView; if (view == null) { return; } if (args.InRecycleQueue == true) { view.Clear(); return; } switch (args.Phase) { case 0: view.ShowPlaceHolder(args.Item as Collection); args.RegisterUpdateCallback(CollectionChanging); break; case 1: view.ShowTitle(); args.RegisterUpdateCallback(CollectionChanging); break; case 2: view.ShowDescription(); args.RegisterUpdateCallback(CollectionChanging); break; case 3: view.ShowAvator(); view.ShowAuthor(); args.RegisterUpdateCallback(CollectionChanging); break; case 4: view.ShowCount(); view.RegistEventHandler(this.CollectionTapped); break; } args.Handled = true; }
public void UpdateSupergroupBanned(IProtoService protoService, ContainerContentChangingEventArgs args, TypedEventHandler <ListViewBase, ContainerContentChangingEventArgs> callback) { var member = args.Item as ChatMember; var messageSender = protoService.GetMessageSender(member.MemberId); if (messageSender == null) { return; } if (args.Phase == 0) { if (messageSender is User user) { TitleLabel.Text = user.GetFullName(); Premium.Visibility = user.IsPremium && protoService.IsPremiumAvailable ? Visibility.Visible : Visibility.Collapsed; } else if (messageSender is Chat chat) { TitleLabel.Text = chat.Title; Premium.Visibility = Visibility.Collapsed; } } else if (args.Phase == 1) { SubtitleLabel.Text = ChannelParticipantToTypeConverter.Convert(protoService, member); } else if (args.Phase == 2) { if (messageSender is User user) { Photo.SetUser(protoService, user, 36); } else if (messageSender is Chat chat) { Photo.SetChat(protoService, chat, 36); } } if (args.Phase < 2) { args.RegisterUpdateCallback(callback); } args.Handled = true; }
private void Column_OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var view = args.ItemContainer.ContentTemplateRoot as ColumnView; if (view == null) { return; } if (args.InRecycleQueue == true) { view.Clear(); } else if (args.Phase == 0) { view.ShowPlaceHolder(args.Item as Column); args.RegisterUpdateCallback(ColumnChanging); } else if (args.Phase == 1) { view.ShowTitle(); args.RegisterUpdateCallback(ColumnChanging); } else if (args.Phase == 2) { view.ShowHeadline(); args.RegisterUpdateCallback(ColumnChanging); } else if (args.Phase == 3) { view.ShowArticlsCount(); args.RegisterUpdateCallback(ColumnChanging); } else if (args.Phase == 4) { view.ShowAvatar(); args.RegisterUpdateCallback(ColumnChanging); } else if (args.Phase == 5) { view.RegistEventHandler(this.ColumnTapped); } args.Handled = true; }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; var venue = args.Item as Venue; var border = content.Children[0] as Border; var bitmap = border.Child as BitmapIcon; bitmap.UriSource = new Uri(string.Format("https://ss3.4sqi.net/img/categories_v2/{0}_88.png", venue.Type)); }
/// <summary> /// Deals with populating categories in this page. /// </summary> /// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param> /// <param name="args">ContainerContentChangingEventArgs args is a parameter called e that contains the event data, see the ContainerContentChangingEventArgs MSDN page for more information.</param> private void GridCategories_ContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { args.Handled = true; if (args.Phase != 0) { throw new Exception("Not in phase 0."); } Categories category = (Categories)args.Item; Grid templateRoot = (Grid)args.ItemContainer.ContentTemplateRoot; Image categoryIcon = (Image)templateRoot.FindName("categoryIcon"); TextBlock categoryName = (TextBlock)templateRoot.FindName("categoryName"); categoryName.Text = category.Name; categoryIcon.Source = new BitmapImage(new Uri(category.Background)); }
private void ThumbanilList_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { Thumbnail thumbnail = args.Item as Thumbnail; Image image = args.ItemContainer.ContentTemplateRoot.GetFirstDescendantOfType <Image>(); Visual visual = ElementCompositionPreview.GetElementVisual(image); visual.Size = new Vector2(960f, 960f); if (_parallaxExpression != null) { _parallaxExpression.SetScalarParameter("StartOffset", (float)args.ItemIndex * visual.Size.Y / 4.0f); visual.StartAnimation("Offset.Y", _parallaxExpression); } }
private void ApplyPhaseOne(ContainerContentChangingEventArgs args) { var templateRoot = args.ItemContainer.ContentTemplateRoot as StackPanel; var hockeyPlayerVM = args.Item as HockeyPlayerViewModel; var numberTextBlock = templateRoot.Children[1] as TextBlock; numberTextBlock.Text = hockeyPlayerVM.Number.ToString(); numberTextBlock.Opacity = 1; var goalsTextBlock = templateRoot.Children[4] as TextBlock; goalsTextBlock.Text = hockeyPlayerVM.Goals.ToString(); goalsTextBlock.Opacity = 1; }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var theme = args.Item as ChatTheme; var cell = args.ItemContainer.ContentTemplateRoot as ChatThemeCell; if (cell != null && theme != null) { cell.Update(_protoService, theme); } }
private void listView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { foreach (var item in VisualHelper.FindVisualChildren <Button>(this)) { if (item.Name == "btnDownload") { item.Visibility = Visibility.Visible; item.IsEnabled = true; } if (item.Name == "btnOpen") { item.Visibility = Visibility.Collapsed; } } }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { return; } var content = args.ItemContainer.ContentTemplateRoot as UserCell; var member = args.Item as ChatMember; args.ItemContainer.Tag = args.Item; content.Tag = args.Item; content.UpdateSupergroupBanned(ViewModel.ProtoService, args, OnContainerContentChanging); }
internal bool Phase1Load(ListViewBase sender, ContainerContentChangingEventArgs args) { if (!args.InRecycleQueue) { if (args.Item is CommentViewModel) { contentControl.MinHeight = 0; contentControl.ContentTemplate = Resources["textTemplate"] as DataTemplate; contentControl.Content = ((CommentViewModel)args.Item).Body; args.Handled = true; LoadPhase = 2; return true; } else throw new NotImplementedException(); } return false; }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { switch (args.Phase) { case 0: args.RegisterUpdateCallback(OnContainerContentChanging); break; case 1: ApplyPhaseOne(args); args.RegisterUpdateCallback(OnContainerContentChanging); break; case 2: ApplyPhaseTwo(args); break; default: break; } // Set args.Handled = true if using x:Bind to skip apply DataContext args.Handled = true; }
internal bool PhaseLoad(ListViewBase sender, ContainerContentChangingEventArgs args) { var dataContext = args.Item as LinkViewModel; var button = ((FrameworkElement)args.ItemContainer.ContentTemplateRoot).FindName("previewSection") as Button; if (args.InRecycleQueue) { dataContext.Content.CancelLoad(); button.Content = null; } else { switch (args.Phase) { case 0: var result = Preview.LoadLinkPreview(dataContext.Content); button.Content = result; return true; case 1: var preview = button.Content as Preview; var finishLoad2 = new Action(async () => { try { await Task.Run(async () => { await preview.FinishLoad(dataContext.Content.CancelToken); }); } catch (TaskCanceledException) { } }); finishLoad2(); return false; } } return false; }
/// <summary> /// Bind Compositon Images to the list which need to continue to the next page on navigation. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void FruitsList_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { //Get the clicked Item var item = args.Item as Item; //Get hold of the UIElement to bind items. var contentPanel = args.ItemContainer.ContentTemplateRoot as StackPanel; //Create Composition Image from data source var parentRectangle = _compositor.CreateContainerVisual(); var rectangleColor = _compositor.CreateSpriteVisual(); rectangleColor.Size = new System.Numerics.Vector2(40,40); //Use ImageFactory to load image from URI. try { CompositionImageFactory imageFactory = CompositionImageFactory.CreateCompositionImageFactory(_compositor); CompositionImageOptions options = new CompositionImageOptions() { DecodeWidth = 160, DecodeHeight = 160, }; CompositionImage image = imageFactory.CreateImageFromUri(item.imageUri, options); rectangleColor.Brush = _compositor.CreateSurfaceBrush(image.Surface); } catch { rectangleColor.Brush = _compositor.CreateColorBrush(Windows.UI.Colors.Red); } //Bind Composition Image to UIElement - Rectangle in this case. Rectangle rectImage = contentPanel.FindName("imageItem") as Rectangle; parentRectangle.Children.InsertAtTop(rectangleColor); item.imageContainerVisual = parentRectangle; item.rectImage = rectImage; ElementCompositionPreview.SetElementChildVisual(rectImage, parentRectangle); }
private void ItemsListView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { // This function manually sets the height of the item ListViewPersistenceHelper is attempting to scroll to. We need to set the height // because if the item is not fully rendered at the time of scrolling, it can return an incorrect height and cause ListViewPersistenceHelper // to overscroll. var singleItem = args.Item as Item; if (singleItem != null && singleItem.Id == _persistedItemKey) { if (!args.InRecycleQueue) { // Here we set the container's height equal to the fully rendered container height we had saved before navigating away. If all the items in // your list have the same fixed height, you can replace this variable with a hardcoded height value. args.ItemContainer.Height = _persistedItemContainerHeight; } else { // Containers in a list are recycled when they are scrolled out of view. However, if those containers have their Height property set and the content // changes, that set Height is still applied. This creates an incorect UI if the items in your list are supposed to be of variable height. // If all the items in your list have the same fixed height, you do not have to do this. args.ItemContainer.ClearValue(HeightProperty); } } }
private void ItemListView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var songViewer = args.ItemContainer.ContentTemplateRoot as SongViewer; if (songViewer == null) return; if (args.InRecycleQueue) { songViewer.ClearData(); } else switch (args.Phase) { case 0: songViewer.ShowPlaceholder((args.Item as QueueSong).Song, true); args.RegisterUpdateCallback(ContainerContentChangingDelegate); break; case 1: songViewer.ShowTitle(); args.RegisterUpdateCallback(ContainerContentChangingDelegate); break; case 2: songViewer.ShowRest(); break; } // For imporved performance, set Handled to true since app is visualizing the data item args.Handled = true; }
private void GridScreenshots_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { args.Handled = true; if (args.Phase != 0) { throw new Exception("Not in phase 0."); } StackPanel templateRoot = (StackPanel)args.ItemContainer.ContentTemplateRoot; Image appIcon = (Image)templateRoot.FindName("appScreenshots"); appIcon.Opacity = 0; args.RegisterUpdateCallback(ShowImages); }
private static void OnContainerContextChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (!args.InRecycleQueue && args.Item is INavigationMenuItem) { args.ItemContainer.SetValue(AutomationProperties.NameProperty, ((INavigationMenuItem) args.Item).Label); } else { args.ItemContainer.ClearValue(AutomationProperties.NameProperty); } }
private void myGridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { Sleep(1); if (args.Phase < 10) args.RegisterUpdateCallback(myGridView_ContainerContentChanging); }
private void ContentListView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var iv = args.ItemContainer.ContentTemplateRoot as IllustrationView; if (args.InRecycleQueue) { return; iv.ClearContent(); //var imageContent = iv.FindName("ImageContent") as Image; //var textContent = iv.FindName("TextContent") as TextBlock; //var progressIndicator = iv.FindName("ProgressBar") as ProgressBar; //var commentIndicator = iv.FindName("CommentIndicator") as Rectangle; //progressIndicator.Value = 0; //if (imageContent.Source != null) //{ // var bitmap = imageContent.Source as BitmapImage; // bitmap.DownloadProgress -= Image_DownloadProgress; //} //imageContent.DataContext = null; //imageContent.ClearValue(Image.SourceProperty); //imageContent.Visibility = Windows.UI.Xaml.Visibility.Collapsed; //imageContent.Height = 0; //textContent.ClearValue(TextBlock.TextProperty); iv.Height = double.NaN; args.ItemContainer.InvalidateMeasure(); args.Handled = true; return; } if (args.Phase == 0) { var line = (LineViewModel)args.Item; if (!Double.IsNaN(sender.ActualWidth) && sender.ActualWidth > 0) iv.MaxWidth = sender.ActualWidth; iv.ResetPhase0(line); //var imageContent = iv.FindName("ImageContent") as Image; //var textContent = iv.FindName("TextContent") as TextBlock; //var commentIndicator = iv.FindName("CommentIndicator") as Rectangle; //var progressIndicator = iv.FindName("ProgressBar") as ProgressBar; //var imagePlaceHolder = iv.FindName("ImagePlaceHolder") as Windows.UI.Xaml.Shapes.Path; //iv.Height = double.NaN; //imageContent.Opacity = 0; //imageContent.Height = double.NaN; //commentIndicator.Opacity = 0; //progressIndicator.Opacity = 0; //textContent.Opacity = 1; //if (imageContent.Source != null) //{ // var bitmap = imageContent.Source as BitmapImage; // bitmap.DownloadProgress -= Image_DownloadProgress; // imageContent.ClearValue(Image.SourceProperty); //} //if (line.IsImage) //{ // if (!AppGlobal.ShouldAutoLoadImage) // textContent.Text = ImageTapToLoadPlaceholder; // else // textContent.Text = ImageLoadingTextPlaceholder; // double aspect = (double)line.ImageHeight / (double)line.ImageWidth; // double ih = iv.Width * aspect; // if (ih <= 1.0) // ih = 440; // imageContent.Height = ih; // imagePlaceHolder.Height = ih; // progressIndicator.Visibility = Visibility.Visible; // imageContent.Visibility = Windows.UI.Xaml.Visibility.Visible; // imagePlaceHolder.Visibility = Windows.UI.Xaml.Visibility.Visible; // textContent.TextAlignment = TextAlignment.Center; //} //else //{ // textContent.Text = " " + line.Content; // //textContent.Height = double.NaN; // textContent.TextAlignment = TextAlignment.Left; // imagePlaceHolder.Visibility = Windows.UI.Xaml.Visibility.Collapsed; // imageContent.Visibility = Windows.UI.Xaml.Visibility.Collapsed; // imageContent.DataContext = null; //} args.RegisterUpdateCallback(ContentListView_ContainerContentChanging); //} else if (args.Phase == 1) //{ // //var textContent = iv.FindName("TextContent") as TextBlock; // //textContent.Opacity = 1; // //args.RegisterUpdateCallback(ContentListView_ContainerContentChanging); } else if (args.Phase == 1) // Show comment indicator rectangle / progress bar { var line = (LineViewModel)args.Item; var commentIndicator = iv.FindName("CommentIndicator") as Rectangle; if (line.HasComments) { commentIndicator.Opacity = 1; args.RegisterUpdateCallback(3, ContentListView_ContainerContentChanging); } if (line.IsImage) { var progressIndicator = iv.FindName("ProgressBar") as ProgressBar; progressIndicator.Value = 0; progressIndicator.Opacity = 1; if (AppGlobal.ShouldAutoLoadImage) args.RegisterUpdateCallback(2, ContentListView_ContainerContentChanging); } } else if (args.Phase == 2) { var line = (LineViewModel)args.Item; iv.LoadIllustrationLine(line); //LoadItemIllustation(iv, line); } //} //else if (args.Phase == 3) //{ // var line = (LineViewModel)args.Item; // line.LoadCommentsAsync(); //} args.Handled = true; }
/// <summary> /// Deals with populating images(app icons) in the AppsPage. /// </summary> /// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param> /// <param name="args">ContainerContentChangingEventArgs args is a parameter called e that contains the event data, see the ContainerContentChangingEventArgs MSDN page for more information.</param> private void ShowImage(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.Phase != 1) { throw new Exception("Not in phase 1."); } Apps app = (Apps)args.Item; StackPanel templateRoot = (StackPanel)args.ItemContainer.ContentTemplateRoot; Image appIcon = (Image)templateRoot.FindName("appIcon"); appIcon.Source = new BitmapImage(new Uri(app.AppIcon)); }
/// <summary> /// Deals with populating images(screenshots) in the App-Details Page. /// </summary> /// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param> /// <param name="args">ContainerContentChangingEventArgs args is a parameter called e that contains the event data, see the ContainerContentChangingEventArgs MSDN page for more information.</param> private void ShowImages(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.Phase != 1) { throw new Exception("Not in phase 1."); } SelectorItem itemContainer = (SelectorItem)args.ItemContainer; StackPanel templateRoot = (StackPanel)itemContainer.ContentTemplateRoot; Image appImage = (Image)templateRoot.FindName("appScreenshots"); appImage.Source = new BitmapImage(new Uri(args.Item.ToString())); appImage.Opacity = 1; }