public async override void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if ((args.Item is ImageItem imageItem)) { await imageItem.TryLoadBitmapAsync(); } }
private static void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer != null) { PokeUIElementZIndex(args.ItemContainer); } }
private async void FileList_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { // This resizes the items after the item template has been changed and reloaded if (itemTemplateChanging) { itemTemplateChanging = false; Behaviors.StretchedGridViewItems.ResizeItems(FileList); } if (args.ItemContainer == null) { GridViewItem gvi = new GridViewItem(); args.ItemContainer = gvi; } args.ItemContainer.DataContext = args.Item; InitializeDrag(args.ItemContainer); if (args.Item is ListedItem item && !item.ItemPropertiesInitialized) { args.ItemContainer.PointerPressed += FileListGridItem_PointerPressed; args.ItemContainer.CanDrag = args.ItemContainer.IsSelected; // Update CanDrag item.ItemPropertiesInitialized = true; await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(item, currentIconSize); } }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { var typeName = args.Item.GetType().Name; Debug.Assert(_typeToItemHashSetMapping.ContainsKey(typeName), "The type of the item used with DataTemplateSelectorBehavior must have a DataTemplate mapping"); var relevantHashSet = _typeToItemHashSetMapping[typeName]; // args.ItemContainer is used to indicate whether the ListView is proposing an // ItemContainer (ListViewItem) to use. If args.Itemcontainer != null, then there was a // recycled ItemContainer available to be reused. if (args.ItemContainer != null) { if (args.ItemContainer.Tag.Equals(typeName)) { // Suggestion matches what we want, so remove it from the recycle queue relevantHashSet.Remove(args.ItemContainer); #if ENABLE_DEBUG_SPEW Debug.WriteLine($"Removing (suggested) {args.ItemContainer.GetHashCode()} from {typeName}"); #endif // ENABLE_DEBUG_SPEW } else { // The ItemContainer's datatemplate does not match the needed // datatemplate. // Don't remove it from the recycle queue, since XAML will resuggest it later args.ItemContainer = null; } } // If there was no suggested container or XAML's suggestion was a miss, pick one up from the recycle queue // or create a new one if (args.ItemContainer == null) { // See if we can fetch from the correct list. if (relevantHashSet.Count > 0) { // Unfortunately have to resort to LINQ here. There's no efficient way of getting an arbitrary // item from a hashset without knowing the item. Queue isn't usable for this scenario // because you can't remove a specific element (which is needed in the block above). args.ItemContainer = relevantHashSet.First(); relevantHashSet.Remove(args.ItemContainer); #if ENABLE_DEBUG_SPEW Debug.WriteLine($"Removing (reused) {args.ItemContainer.GetHashCode()} from {typeName}"); #endif // ENABLE_DEBUG_SPEW } else { // There aren't any (recycled) ItemContainers available. So a new one // needs to be created. var item = CreateSelectorItem(typeName); args.ItemContainer = item; #if ENABLE_DEBUG_SPEW Debug.WriteLine($"Creating {args.ItemContainer.GetHashCode()} for {typeName}"); #endif // ENABLE_DEBUG_SPEW } } // Indicate to XAML that we picked a container for it args.IsContainerPrepared = true; }
public async override void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args != null && args.Item is DownloadItem item) { await item?.ImageItem?.TryLoadBitmapAsync(); } }
protected virtual void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { if (sender is ListView) { args.ItemContainer = new TableAccessibleChatListViewItem(ViewModel.ProtoService); } else { args.ItemContainer = new ChatGridViewItem(ViewModel.ProtoService); } args.ItemContainer.Style = sender.ItemContainerStyle; args.ItemContainer.ContentTemplate = sender.ItemTemplate; args.ItemContainer.ContextRequested += Message_ContextRequested; } if (sender.ItemTemplateSelector != null) { args.ItemContainer.ContentTemplate = sender.ItemTemplateSelector.SelectTemplate(args.Item, args.ItemContainer); } args.IsContainerPrepared = true; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { if (sender.ItemsPanel == VerticalStack) { args.ItemContainer = new ListViewItem(); } else { args.ItemContainer = new GridViewItem { Margin = new Thickness(2) }; } if (sender.ItemTemplateSelector != null) { args.ItemContainer.ContentTemplate = sender.ItemTemplateSelector.SelectTemplate(args.Item, args.ItemContainer); } else { args.ItemContainer.ContentTemplate = sender.ItemTemplate; } args.ItemContainer.HorizontalContentAlignment = HorizontalAlignment.Stretch; args.ItemContainer.VerticalContentAlignment = VerticalAlignment.Stretch; _zoomer.ElementPrepared(args.ItemContainer); } args.IsContainerPrepared = true; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { var typeName = args.Item is ViewModels.Drawers.StickerViewModel sticker ? sticker.Format switch { StickerFormatTgs => "AnimatedItemTemplate", StickerFormatWebm => "VideoItemTemplate", _ => "ItemTemplate" } : "ItemTemplate";
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { var stickerSet = args.Item as StickerSetInfo; var cover = stickerSet.GetThumbnail(out _, out bool animated); var typeName = animated ? "AnimatedItemTemplate" : "ItemTemplate"; var relevantHashSet = _typeToItemHashSetMapping[typeName]; // args.ItemContainer is used to indicate whether the ListView is proposing an // ItemContainer (ListViewItem) to use. If args.Itemcontainer != null, then there was a // recycled ItemContainer available to be reused. if (args.ItemContainer != null) { if (args.ItemContainer.Tag.Equals(typeName)) { // Suggestion matches what we want, so remove it from the recycle queue relevantHashSet.Remove(args.ItemContainer); } else { // The ItemContainer's datatemplate does not match the needed // datatemplate. // Don't remove it from the recycle queue, since XAML will resuggest it later args.ItemContainer = null; } } // If there was no suggested container or XAML's suggestion was a miss, pick one up from the recycle queue // or create a new one if (args.ItemContainer == null) { // See if we can fetch from the correct list. if (relevantHashSet.Count > 0) { // Unfortunately have to resort to LINQ here. There's no efficient way of getting an arbitrary // item from a hashset without knowing the item. Queue isn't usable for this scenario // because you can't remove a specific element (which is needed in the block above). args.ItemContainer = relevantHashSet.First(); relevantHashSet.Remove(args.ItemContainer); } else { // There aren't any (recycled) ItemContainers available. So a new one // needs to be created. var item = new ListViewItem(); item.ContentTemplate = _typeToTemplateMapping[typeName]; item.Style = sender.ItemContainerStyle; item.Tag = typeName; item.ContextRequested += StickerSet_ContextRequested; args.ItemContainer = item; } } // Indicate to XAML that we picked a container for it args.IsContainerPrepared = true; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new MultipleListViewItem(false); args.ItemContainer.Style = List.ItemContainerStyle; args.ItemContainer.ContentTemplate = List.ItemTemplate; } args.IsContainerPrepared = true; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new TextListViewItem(); args.ItemContainer.Style = ScrollingHost.ItemContainerStyle; } args.ItemContainer.ContentTemplate = ScrollingHost.ItemTemplateSelector.SelectTemplate(args.Item); args.IsContainerPrepared = true; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (_needUpdate) { var root = ItemsPanelRoot as ItemsStackPanel; if (root != null) { root.Orientation = Orientation; _needUpdate = false; } } }
private void ChatsList_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new ChatsListViewItem(ChatsList); args.ItemContainer.Style = ChatsList.ItemContainerStyle; args.ItemContainer.ContentTemplate = ChatsList.ItemTemplate; args.ItemContainer.ContextRequested += Chat_ContextRequested; } args.IsContainerPrepared = true; }
protected override void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new TableListViewItem(); args.ItemContainer.Style = ScrollingHost.ItemContainerStyle; } args.ItemContainer.ContentTemplate = ScrollingHost.ItemTemplate; args.IsContainerPrepared = true; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new ListViewItem(); args.ItemContainer.Style = sender.ItemContainerStyle; args.ItemContainer.ContentTemplate = sender.ItemTemplate; args.ItemContainer.ContextRequested += Member_ContextRequested; } args.IsContainerPrepared = true; }
public async override void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if ((args.Item is ImageItem imageItem)) { await imageItem.TryLoadBitmapAsync(); if (imageItem.Image.IsInHighlightList) { await imageItem.LoadAuthorInfoAsync(); } } }
private void AssociatedObject_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { var context = args.Item; if (_map.Contains(context)) { return; } Microsoft.Xaml.Interactivity.Interaction.ExecuteActions(context, Actions, null); _map.Add(context); }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new GridViewItem(); args.ItemContainer.ContentTemplate = sender.ItemTemplate; args.ItemContainer.Style = sender.ItemContainerStyle; _zoomer.ElementPrepared(args.ItemContainer); } args.IsContainerPrepared = true; }
private void ListView_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { Debug.WriteLine(args.ItemContainer); var container = new ListViewItem(); //container.PointerPressed += Container_PointerPressed; //container.PointerMoved += Container_PointerMoved; //container.PointerReleased += Container_PointerReleased; container.DragStarting += Container_DragStarting; container.DropCompleted += Container_DropCompleted; args.ItemContainer = container; }
private void Listview_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer != null) { return; } ListViewItem container = (ListViewItem)args.ItemContainer ?? new ListViewItem(); container.IsDoubleTapEnabled = true; container.DoubleTapped += Container_DoubleTapped; args.ItemContainer = container; }
private void locationsListView_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer != null) { return; } ListViewItem containerItem = new ListViewItem(); containerItem.PointerEntered += ContainerItem_PointerEntered; containerItem.PointerExited += ContainerItem_PointerExited; args.ItemContainer = containerItem; }
private void ListView_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { var viewType = dataSource.GetItemViewType(args.ItemIndex); var info = templateSelector.GetInfo(Element.Adapter, args.ItemIndex); // Can we reuse the container? if (args?.ItemContainer?.Tag is WrapperItem wrapper) { if (wrapper.ViewType == viewType) { if (args.ItemContainer is ListViewItem lvi) { wrapper.Control.Update(info); lvi.Content = wrapper.Control; lvi.InvalidateMeasure(); } } } else { args.IsContainerPrepared = true; var template = templateSelector.GetTemplate(Element.Adapter, args.ItemIndex); var viewCell = template.CreateContent() as VirtualViewCell; var container = new UwpControlWrapper(viewCell.View); container.ViewCell = viewCell; container.Update(info); Unparent(container); //args.IsContainerPrepared = true; //c.Content = container; var listViewItem = new ListViewItem(); listViewItem.Content = container; args.ItemContainer = listViewItem; args.ItemContainer.Tag = new WrapperItem { Control = container, ViewType = viewType }; args.IsContainerPrepared = true; } }
private void DownloadListView_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { // Do we already have an ItemContainer? If so, we're done here. if (args.ItemContainer != null) { return; } ListViewItem containerItem = new ListViewItem(); // Show hover buttons containerItem.PointerEntered += ContainerItem_PointerEntered; containerItem.PointerExited += ContainerItem_PointerExited; args.ItemContainer = containerItem; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new GridViewItem(); args.ItemContainer.Style = sender.ItemContainerStyle; args.ItemContainer.ContentTemplate = sender.ItemTemplate; args.ItemContainer.ContextRequested += Sticker_ContextRequested; if (ApiInfo.IsFullExperience || Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == Windows.UI.ViewManagement.UserInteractionMode.Mouse) { _zoomer.ElementPrepared(args.ItemContainer); } } args.IsContainerPrepared = true; }
private async void FileList_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new ListViewItem(); } args.ItemContainer.DataContext = args.Item; if (args.Item is ListedItem item && !item.ItemPropertiesInitialized) { args.ItemContainer.PointerPressed += FileListGridItem_PointerPressed; InitializeDrag(args.ItemContainer); args.ItemContainer.CanDrag = args.ItemContainer.IsSelected; // Update CanDrag item.ItemPropertiesInitialized = true; await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(item, currentIconSize); } }
private void GridView_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer != null) { return; } GridViewItem container = (GridViewItem)args.ItemContainer ?? new GridViewItem(); container.PointerEntered -= ItemContainer_PointerEntered; container.PointerExited -= ItemContainer_PointerExited; container.PointerEntered += ItemContainer_PointerEntered; container.PointerExited += ItemContainer_PointerExited; container.Tapped += Container_Tapped; args.ItemContainer = container; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { if (sender is ListView) { args.ItemContainer = new AccessibleChatListViewItem(ViewModel.ProtoService); } else { args.ItemContainer = new ChatGridViewItem(ViewModel.ProtoService); } args.ItemContainer.Style = sender.ItemContainerStyle; } args.ItemContainer.ContentTemplate = sender.ItemTemplateSelector.SelectTemplate(args.Item, args.ItemContainer); args.IsContainerPrepared = true; }
private void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.Item is ISessionService && (args.ItemContainer == null || args.ItemContainer is Controls.NavigationViewItem || args.ItemContainer is Controls.NavigationViewItemSeparator)) { args.ItemContainer = new ListViewItem(); args.ItemContainer.Style = NavigationViewList.ItemContainerStyle; args.ItemContainer.ContentTemplate = Resources["SessionItemTemplate"] as DataTemplate; args.ItemContainer.ContextRequested += OnContextRequested; } else if (args.Item is RootDestination destination) { if (destination == RootDestination.Separator && args.ItemContainer is not Controls.NavigationViewItemSeparator) { args.ItemContainer = new Controls.NavigationViewItemSeparator(); } else if (destination != RootDestination.Separator && args.ItemContainer is not Controls.NavigationViewItem) { args.ItemContainer = new Controls.NavigationViewItem(); args.ItemContainer.ContextRequested += OnContextRequested; } }
protected override void OnChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { if (args.ItemContainer == null) { args.ItemContainer = new TableListViewItem(); args.ItemContainer.Style = sender.ItemContainerStyle; args.ItemContainer.ContextRequested += Member_ContextRequested; if (sender.ItemTemplateSelector == null) { args.ItemContainer.ContentTemplate = sender.ItemTemplate; } } if (sender.ItemTemplateSelector != null) { args.ItemContainer.ContentTemplate = sender.ItemTemplateSelector.SelectTemplate(args.Item, args.ItemContainer); } args.IsContainerPrepared = true; }
private void PhotoCollectionViewer_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args) { args.ItemContainer = args.ItemContainer ?? new GridViewItem(); var fadeIn = _compositor.CreateScalarKeyFrameAnimation(); fadeIn.Target = "Opacity"; fadeIn.Duration = TimeSpan.FromMilliseconds(_animationDuration); fadeIn.InsertKeyFrame(0, 0); fadeIn.InsertKeyFrame(1, 1); fadeIn.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay; fadeIn.DelayTime = TimeSpan.FromMilliseconds(_animationDuration * 0.125 * args.ItemIndex); var fadeOut = _compositor.CreateScalarKeyFrameAnimation(); fadeOut.Target = "Opacity"; fadeOut.Duration = TimeSpan.FromMilliseconds(_animationDuration); fadeOut.InsertKeyFrame(1, 0); var scaleIn = _compositor.CreateVector3KeyFrameAnimation(); scaleIn.Target = "Scale"; scaleIn.Duration = TimeSpan.FromMilliseconds(_animationDuration); scaleIn.InsertKeyFrame(0f, new Vector3(1.2f, 1.2f, 1.2f)); scaleIn.InsertKeyFrame(1f, new Vector3(1f, 1f, 1f)); scaleIn.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay; scaleIn.DelayTime = TimeSpan.FromMilliseconds(_animationDuration * 0.125 * args.ItemIndex); // animations set to run at the same time are grouped var animationFadeInGroup = _compositor.CreateAnimationGroup(); animationFadeInGroup.Add(fadeIn); animationFadeInGroup.Add(scaleIn); // Set up show and hide animations for this item container before the element is added to the tree. // These fire when items are added/removed from the visual tree, including when you set Visibilty ElementCompositionPreview.SetImplicitShowAnimation(args.ItemContainer, animationFadeInGroup); ElementCompositionPreview.SetImplicitHideAnimation(args.ItemContainer, fadeOut); }