Inheritance: Windows.UI.Xaml.Controls.Primitives.Selector, IListViewBase, ISemanticZoomInformation
        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;
        }
Exemplo n.º 2
0
        private void OnAdjusterListContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            if (!args.InRecycleQueue)
            {
                args.ItemContainer.Loaded += OnItemContainerLoaded;
            }

            void OnItemContainerLoaded(object s, RoutedEventArgs e)
            {
                args.ItemContainer.Loaded -= OnItemContainerLoaded;

                // Don't animate if it's not in the visible viewport.
                if (AdjusterList.ItemsPanelRoot is ItemsStackPanel itemsPanel &&
                    args.ItemContainer.FindDescendant <ListViewItemPresenter>() is ListViewItemPresenter itemPresenter &&
                    args.ItemIndex >= itemsPanel.FirstVisibleIndex && args.ItemIndex <= itemsPanel.LastVisibleIndex)
                {
                    var delay   = (args.ItemIndex - itemsPanel.FirstVisibleIndex) * 100;
                    var centerX = (float)itemPresenter.RenderSize.Width / 2;
                    var centerY = (float)itemPresenter.RenderSize.Height / 2;

                    itemPresenter.Fade(0.0f, 0).Then().Fade(1.0f, 600, delay).Start();
                    itemPresenter.Scale(0.6f, 0.6f, centerX, centerY, 0).Then().Scale(1.0f, 1.0f, centerX, centerY, 600, delay).Start();
                }
            }
        }
Exemplo n.º 3
0
 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;
 }
        /// <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 void ListView_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            _instance = sender as Windows.UI.Xaml.Controls.ListViewBase;

            if (e.Pointer.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                return;
            }

            var position = e.GetCurrentPoint(_instance).Position;
            var oldRate  = _rate;

            if (position.X < _threshold)
            {
                _rate = position.X - _threshold;
            }
            else if (_instance.ActualWidth - position.X < _threshold)
            {
                _rate = _threshold - (_instance.ActualWidth - position.X);
            }
            else
            {
                _rate = 0;
            }

            if (oldRate == 0 && _rate != 0)
            {
                var t = ScrollListView();
            }
        }
Exemplo n.º 6
0
        /// <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;
        }
Exemplo n.º 7
0
        public static void ScrollItem(ListViewBase control, int indexDelta)
        {
            if (control == null || control.Items == null)
                return;

            var scrollViewer = VisualTreeUtilities.GetVisualChild<ScrollViewer>(control);

            var p = new Point(Window.Current.Bounds.Width/2, 10);
            var transform = control.TransformToVisual(Window.Current.Content);
            var checkPoint = transform.TransformPoint(p);

            var q = from lvi in VisualTreeHelper.FindElementsInHostCoordinates(checkPoint, scrollViewer).OfType<ListViewItem>()
                where lvi.Content != null
                select lvi.Content;

            var item = q.FirstOrDefault();

            if (item == null)
                return;

            var index = control.Items.IndexOf(item);
            var nextItemIndex = index + indexDelta;
            if (index != -1 && nextItemIndex >= 0 && nextItemIndex < control.Items.Count)
            {
                var nextItem = control.Items[nextItemIndex];
                control.ScrollIntoView(nextItem, ScrollIntoViewAlignment.Leading);
            }
        }
Exemplo n.º 8
0
 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;
             }
         }
     }
 }
Exemplo n.º 9
0
        //SignoffStatus Grid Select Event : Load WorkFlowBar 
        private async void lvListSelectionChanged_Changed(object sender, ListViewBase e)
        {
            try
            {
                ucWorkFlowBanner.GridClear();
                IWPWorkflowStatusdto = (IWPWorkflowStatusBypersonnelid_type_term)e.SelectedItem;
                List<WorkflowDetailByIWPID> workflowbannerdto = new List<WorkflowDetailByIWPID>();
                await _Workflow.GetWorkflowDetailByProcessID(IWPWorkflowStatusdto.ProcessId);
                workflowbannerdto = _Workflow.GetWorkflowDetail();
                ucWorkFlowBanner.LoadWorkFlow(workflowbannerdto);

                Lib.WorkFlowDataSource.PackageTypeCode = IWPWorkflowStatusdto.PackageTypeCode;

                Lib.WorkFlowDataSource.selectedTypeName = IWPWorkflowStatusdto.PackageTypeName;
                Lib.WorkFlowDataSource.selectedDocumentID = IWPWorkflowStatusdto.TargetId;
                Lib.WorkFlowDataSource.selectedIwpID = IWPWorkflowStatusdto.IwpId;
                
                if (btnsentstatus != "")
                    Lib.WorkFlowDataSource.sentyn = btnsentstatus;
            }
            catch (Exception ex)
            {

            }
        }
Exemplo n.º 10
0
        private static void RegisterListItem(this Page page, Windows.UI.Xaml.Controls.ListViewBase listViewBase, string key, string elementName)
        {
            if (listViewBase == null || string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(elementName))
            {
                return;
            }

            var props = GetPageConnectedAnimationProperties(page);

            if (!props.TryGetValue(key, out var prop))
            {
                prop = new ConnectedAnimationProperties
                {
                    Key = key,
                    ListAnimProperties = new List <ConnectedAnimationListProperty>()
                };
                props[key] = prop;
            }

            if (!prop.ListAnimProperties.Any(lap => lap.ListViewBase == listViewBase && lap.ElementName == elementName))
            {
                prop.ListAnimProperties.Add(new ConnectedAnimationListProperty
                {
                    ElementName  = elementName,
                    ListViewBase = listViewBase
                });
            }
        }
Exemplo n.º 11
0
        private static void RemoveListItem(this Page page, Windows.UI.Xaml.Controls.ListViewBase listViewBase, string key)
        {
            if (listViewBase == null || string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            var props = GetPageConnectedAnimationProperties(page);

            if (props.TryGetValue(key, out var prop))
            {
                if (!prop.IsListAnimation)
                {
                    props.Remove(key);
                }
                else
                {
                    var listAnimProperty = prop.ListAnimProperties.FirstOrDefault(lap => lap.ListViewBase == listViewBase);
                    if (listAnimProperty != null)
                    {
                        prop.ListAnimProperties.Remove(listAnimProperty);
                        if (prop.ListAnimProperties.Count == 0)
                        {
                            props.Remove(key);
                        }
                    }
                }
            }
        }
        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 OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            var visual = ElementCompositionPreview.GetElementVisual(args.ItemContainer);

            visual.ImplicitAnimations = args.InRecycleQueue
                ? null
                : animations;
        }
Exemplo n.º 14
0
		private static void ClearPreviousEvents(ListViewBase listView)
		{
			ItemClickEventHandler eventHandler;
			if (_eventHandlers.TryGetValue(listView, out eventHandler))
			{
				listView.ItemClick -= eventHandler;
				_eventHandlers.Remove(listView);
			}
		}
Exemplo n.º 15
0
 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);
     }
 }
 internal void Detach()
 {
     _listView.SelectionChanged -= OnListViewSelectionChanged;
     _listView = null;
     var eventInfo =
         _boundSelection.GetType().GetDeclaredEvent("CollectionChanged");
     eventInfo.RemoveEventHandler(_boundSelection, _handler);
     _boundSelection = null;
 }
Exemplo n.º 17
0
 private bool TrySelectItem(ListViewBase listView, Func<object, bool> predicator)
 {
     var item = listView.Items.FirstOrDefault(predicator);
     if (item != null)
     {
         listView.SelectedItem = item;
         return true;
     }
     return false;
 }
Exemplo n.º 18
0
		private static void HandleItemClick(ListViewBase listView, object item)
		{
			var command = GetCommand(listView);

			if (command == null || !command.CanExecute(item))
			{
				return;
			}
			command.Execute(item);
		}
Exemplo n.º 19
0
 private static void SetItemContainerBackground(Windows.UI.Xaml.Controls.ListViewBase sender, Control itemContainer, int itemIndex)
 {
     if (itemIndex % 2 == 0)
     {
         itemContainer.Background = GetAlternateColor(sender);
     }
     else
     {
         itemContainer.Background = null;
     }
 }
Exemplo n.º 20
0
        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);
            }
        }
Exemplo n.º 21
0
        private static void OnListViewBaseUnloaded(object sender, RoutedEventArgs e)
        {
            Windows.UI.Xaml.Controls.ListViewBase listViewBase = sender as Windows.UI.Xaml.Controls.ListViewBase;
            _itemsForList.Remove(listViewBase.Items);

            listViewBase.ContainerContentChanging -= StretchItemContainerDirectionChanging;
            listViewBase.ContainerContentChanging -= ItemTemplateContainerContentChanging;
            listViewBase.ContainerContentChanging -= ColorContainerContentChanging;
            listViewBase.Items.VectorChanged      -= ColorItemsVectorChanged;
            listViewBase.Unloaded -= OnListViewBaseUnloaded;
        }
 private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
 {
     if (args.InRecycleQueue)
     {
         if (_index > _associatedObject.Items.Count - 1)
         {
             _index = _associatedObject.Items.Count - 1;
         }
         _associatedObject.SelectedIndex = _index;
     }
 }
Exemplo n.º 23
0
		/// <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);
			}
		}
Exemplo n.º 24
0
        private static void RemoveListItem(this Page page, Windows.UI.Xaml.Controls.ListViewBase listViewBase, string key)
        {
            if (listViewBase == null || string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            var props = GetPageConnectedAnimationProperties(page);

            props.Remove(key);
        }
 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 Attach(ListViewBase listView, ObservableCollection<object> boundSelection)
        {
            _listView = listView;
            _listView.SelectionChanged += OnListViewSelectionChanged;
            _boundSelection = boundSelection;

            foreach (var item in _boundSelection.Where(item => !_listView.SelectedItems.Contains(item)))
            {
                _listView.SelectedItems.Add(item);
            }

            _boundSelection.CollectionChanged += OnBoundSelectionChanged;
        }
Exemplo n.º 28
0
 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 OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            var containerVisual = VisualExtensions.GetVisual(args.ItemContainer);

            if (args.InRecycleQueue)
            {
                containerVisual.ImplicitAnimations = null;
            }
            else
            {
                Implicit.SetAnimations(args.ItemContainer, OffsetImplicitAnimations);
            }
        }
Exemplo n.º 30
0
        private static void ItemTemplateContainerContentChanging(Windows.UI.Xaml.Controls.ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            var itemContainer = args.ItemContainer as SelectorItem;

            if (args.ItemIndex % 2 == 0)
            {
                itemContainer.ContentTemplate = GetAlternateItemTemplate(sender);
            }
            else
            {
                itemContainer.ContentTemplate = sender.ItemTemplate;
            }
        }
Exemplo n.º 31
0
        private static void ColorContainerContentChanging(Windows.UI.Xaml.Controls.ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            var itemContainer = args.ItemContainer as SelectorItem;
            var itemIndex     = sender.IndexFromContainer(itemContainer);

            if (itemIndex % 2 == 0)
            {
                itemContainer.Background = GetAlternateColor(sender);
            }
            else
            {
                itemContainer.Background = null;
            }
        }
        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 AdaptiveView_ChoosingItemContainer(Windows.UI.Xaml.Controls.ListViewBase sender, ChoosingItemContainerEventArgs args)
 {
     if (args.ItemContainer == null)
     {
         GridViewItem container = (GridViewItem)args.ItemContainer ?? new GridViewItem();
         args.ItemContainer = container;
     }
     nativeadData = args.Item as NativeAdData;
     if (nativeadData is NativeAdData)
     {
         // I am trying to send the container to nativeaD OBJECT in nativeadData so I can register it for clicks.
         nativeadData.parent = args.ItemContainer;
         nativeadData.myNativeAdsManager?.RequestAd();
     }
 }
        private static SelectedItemsBehavior GetOrCreateBehavior(ListViewBase target, IList list)
        {
            var behavior = target.GetValue(SelectedItemsBehaviorProperty) as SelectedItemsBehavior;
            if (behavior == null)
            {
                behavior = new SelectedItemsBehavior(target, list);
                target.SetValue(SelectedItemsBehaviorProperty, behavior);
            }
            else
            {
                behavior.SetData(list);
            }

            return behavior;
        }
Exemplo n.º 35
0
        private void SamplePickerListView_ContainerContentChanging(Windows.UI.Xaml.Controls.ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            if (!AnimationHelper.IsImplicitHideShowSupported)
            {
                return;
            }

            var panel = args.ItemContainer.FindAscendant <DropShadowPanel>();

            if (panel != null)
            {
                ElementCompositionPreview.SetImplicitShowAnimation(panel, AnimationHelper.GetOpacityAnimation(_compositor, 1, 0, _defaultShowAnimationDuration));
                ////ElementCompositionPreview.SetImplicitHideAnimation(panel, GetOpacityAnimation(0, _defaultHideAnimationDiration));
            }
        }
Exemplo n.º 36
0
        private void PatternPickerGridView_ChoosingItemContainer(Windows.UI.Xaml.Controls.ListViewBase sender, ChoosingItemContainerEventArgs args)
        {
            if (args.ItemContainer != null)
            {
                return;
            }

            GridViewItem container = (GridViewItem)args.ItemContainer ?? new GridViewItem();

            container.Loaded         += ContainerItem_Loaded;
            container.PointerEntered += ItemContainer_PointerEntered;
            container.PointerExited  += ItemContainer_PointerExited;

            args.ItemContainer = container;
        }
Exemplo n.º 37
0
        private static void StretchItemContainerDirectionChanging(Windows.UI.Xaml.Controls.ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            var itemContainer    = args.ItemContainer as SelectorItem;
            var stretchDirection = GetItemContainerStretchDirection(sender);

            if (stretchDirection == ItemContainerStretchDirection.Vertical || stretchDirection == ItemContainerStretchDirection.Both)
            {
                itemContainer.VerticalContentAlignment = VerticalAlignment.Stretch;
            }

            if (stretchDirection == ItemContainerStretchDirection.Horizontal || stretchDirection == ItemContainerStretchDirection.Both)
            {
                itemContainer.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Override default OnApplyTemplate to capture children controls
        /// </summary>
        protected override void OnApplyTemplate()
        {
            if (PaneForeground == null)
            {
                PaneForeground = Foreground;
            }

            if (_hamburgerButton != null)
            {
                _hamburgerButton.Click -= HamburgerButton_Click;
            }

            if (_buttonsListView != null)
            {
                _buttonsListView.ItemClick -= ButtonsListView_ItemClick;
            }

            if (_optionsListView != null)
            {
                _optionsListView.ItemClick -= OptionsListView_ItemClick;
            }

            if (UsingNavView)
            {
                OnApplyTemplateNavView();
            }

            _hamburgerButton = (Button)GetTemplateChild("HamburgerButton");
            _buttonsListView = (Windows.UI.Xaml.Controls.ListViewBase)GetTemplateChild("ButtonsListView");
            _optionsListView = (Windows.UI.Xaml.Controls.ListViewBase)GetTemplateChild("OptionsListView");

            if (_hamburgerButton != null)
            {
                _hamburgerButton.Click += HamburgerButton_Click;
            }

            if (_buttonsListView != null)
            {
                _buttonsListView.ItemClick += ButtonsListView_ItemClick;
            }

            if (_optionsListView != null)
            {
                _optionsListView.ItemClick += OptionsListView_ItemClick;
            }

            base.OnApplyTemplate();
        }
Exemplo n.º 39
0
        private static void AddListViewBaseItemAnimationDetails(Page page, Windows.UI.Xaml.Controls.ListViewBase listViewBase)
        {
            if (listViewBase != null)
            {
                var elementName = GetListItemElementName(listViewBase);
                var key         = GetListItemKey(listViewBase);

                if (string.IsNullOrWhiteSpace(elementName) ||
                    string.IsNullOrWhiteSpace(key))
                {
                    return;
                }

                page.RegisterListItemForConnectedAnimation(listViewBase, key, elementName);
            }
        }
Exemplo n.º 40
0
        private static void AddListViewBaseItemAnimationDetails(Page page, Windows.UI.Xaml.Controls.ListViewBase listViewBase)
        {
            if (ApiInformationHelper.IsCreatorsUpdateOrAbove && listViewBase != null)
            {
                var elementName = GetListItemElementName(listViewBase);
                var key         = GetListItemKey(listViewBase);

                if (string.IsNullOrWhiteSpace(elementName) ||
                    string.IsNullOrWhiteSpace(key))
                {
                    return;
                }

                page.RegisterListItem(listViewBase, key, elementName);
            }
        }
Exemplo n.º 41
0
        private void SamplePickerListView_ChoosingItemContainer(Windows.UI.Xaml.Controls.ListViewBase sender, ChoosingItemContainerEventArgs args)
        {
            if (!AnimationHelper.IsImplicitHideShowSupported)
            {
                return;
            }

            args.ItemContainer = args.ItemContainer ?? new ListViewItem();

            var showAnimation = AnimationHelper.GetOpacityAnimation(_compositor, 1, 0, _defaultShowAnimationDuration, 200);

            (showAnimation as ScalarKeyFrameAnimation).DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay;

            ////ElementCompositionPreview.SetImplicitHideAnimation(args.ItemContainer, GetOpacityAnimation(0, _defaultHideAnimationDiration));
            ElementCompositionPreview.SetImplicitShowAnimation(args.ItemContainer, showAnimation);
        }
Exemplo n.º 42
0
        private static void OnStretchItemContainerDirectionPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            Windows.UI.Xaml.Controls.ListViewBase listViewBase = sender as Windows.UI.Xaml.Controls.ListViewBase;

            if (listViewBase == null)
            {
                return;
            }

            listViewBase.ContainerContentChanging -= StretchItemContainerDirectionChanging;

            if (StretchItemContainerDirectionProperty != null)
            {
                listViewBase.ContainerContentChanging += StretchItemContainerDirectionChanging;
            }
        }
Exemplo n.º 43
0
        private static void OnCommandPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            Windows.UI.Xaml.Controls.ListViewBase listViewBase = sender as Windows.UI.Xaml.Controls.ListViewBase;

            if (listViewBase != null)
            {
                listViewBase.ItemClick -= OnItemClicked;

                ICommand command = args.NewValue as ICommand;

                if (command != null)
                {
                    listViewBase.ItemClick += OnItemClicked;
                }
            }
        }
Exemplo n.º 44
0
        private static void OnAlternateItemTemplatePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            Windows.UI.Xaml.Controls.ListViewBase listViewBase = sender as Windows.UI.Xaml.Controls.ListViewBase;

            if (listViewBase == null)
            {
                return;
            }

            listViewBase.ContainerContentChanging -= ItemTemplateContainerContentChanging;

            if (AlternateItemTemplateProperty != null)
            {
                listViewBase.ContainerContentChanging += ItemTemplateContainerContentChanging;
            }
        }
Exemplo n.º 45
0
        private static void OnItemClicked(object sender, ItemClickEventArgs args)
        {
            Windows.UI.Xaml.Controls.ListViewBase listViewBase = sender as Windows.UI.Xaml.Controls.ListViewBase;

            if (listViewBase == null)
            {
                return;
            }

            ICommand command = GetCommand(listViewBase);

            if (command != null && command.CanExecute(args.ClickedItem))
            {
                command.Execute(args.ClickedItem);
            }
        }
        private void Lv_ContainerContentChanging(uwp.ListViewBase sender, uwp.ContainerContentChangingEventArgs args)
        {
            var lv = sender as uwp.ListView;

            var uiElement = (uwp.ListViewItem)lv.ContainerFromItem(_selectedItem);

            if (uiElement != null)
            {
                var itemPresenter = VisualTreeHelper.GetChild(uiElement, 0);
                var cell          = (CellControl)VisualTreeHelper.GetChild(itemPresenter, 0);

                // Subscribe
                _watcher = cell.WatchProperty("Content", CellControl_ContentChanged);

                lv.ContainerContentChanging -= Lv_ContainerContentChanging;
                _selectedItem = null;
            }
        }
Exemplo n.º 47
0
        private static void OnItemContainerStretchDirectionPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            Windows.UI.Xaml.Controls.ListViewBase listViewBase = sender as Windows.UI.Xaml.Controls.ListViewBase;

            if (listViewBase == null)
            {
                return;
            }

            listViewBase.ContainerContentChanging -= ItemContainerStretchDirectionChanging;
            listViewBase.Unloaded -= OnListViewBaseUnloaded;

            if (ItemContainerStretchDirectionProperty != null)
            {
                listViewBase.ContainerContentChanging += ItemContainerStretchDirectionChanging;
                listViewBase.Unloaded += OnListViewBaseUnloaded;
            }
        }
Exemplo n.º 48
0
 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;
 }
Exemplo n.º 49
0
        protected override void OnApplyTemplate()
        {
            if (_playlistsButtonsListView != null)
                _playlistsButtonsListView.ItemClick -= playlistsButtonsListView_ItemClick;
            if (_buttonsListView != null)
                _buttonsListView.ItemClick -= buttonsList_ItemClick;
            if (_optionsListView != null)
                _optionsListView.ItemClick -= optionsListView_ItemClick;

            _playlistsButtonsListView = (ListViewBase)GetTemplateChild("PlaylistsButtonsListView");
            _buttonsListView = (ListViewBase)GetTemplateChild("ButtonsListView");
            _optionsListView = (ListViewBase)GetTemplateChild("OptionsListView");

            _playlistsButtonsListView.ItemClick += playlistsButtonsListView_ItemClick;
            _buttonsListView.ItemClick += buttonsList_ItemClick;
            _optionsListView.ItemClick += optionsListView_ItemClick;

            base.OnApplyTemplate();
        }
Exemplo n.º 50
0
    public ListViewHelper(ListViewBase listView)
    {
        listView.ItemClick += (sender, args) =>
            {
                var methodName = GetItemClickMethodName(listView);

                var method = listView.DataContext.GetType().GetTypeInfo().GetDeclaredMethod(methodName);
                var parms = method.GetParameters();

                if (parms != null && parms.Length == 1)
                {
                    method.Invoke(listView.DataContext, new[] { args.ClickedItem });
                }
                else
                {
                    method.Invoke(listView.DataContext, null);
                }
            };
    }
Exemplo n.º 51
0
        private static void RegisterListItem(this Page page, Windows.UI.Xaml.Controls.ListViewBase listViewBase, string key, string elementName)
        {
            if (listViewBase == null || string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(elementName))
            {
                return;
            }

            var prop = new ConnectedAnimationProperties()
            {
                Key             = key,
                IsListAnimation = true,
                ElementName     = elementName,
                ListViewBase    = listViewBase
            };

            var props = GetPageConnectedAnimationProperties(page);

            props[key] = prop;
        }
Exemplo n.º 52
0
    public ListViewHelper(ListViewBase listView)
    {
        listView.ItemClick += (sender, args) =>
            {
                var methodName = GetItemClickMethodName(listView);

                var method = listView.DataContext.GetType().GetTypeInfo().GetDeclaredMethod(methodName);
                var parms = method.GetParameters();

                if (parms != null && parms.Length == 1)
                {
                    method.Invoke(listView.DataContext, new[] { args.ClickedItem });
                }
                else
                {
                    method.Invoke(listView.DataContext, null);
                }
            };

            listView.SelectionChanged += (sender, args) =>
            {
                var methodName = GetItemClickMethodName(listView);

                var dataContext = GetMethodContext(listView);
                if (dataContext == null)
                {
                    dataContext = listView.DataContext;
                }

                var method = dataContext.GetType().GetTypeInfo().GetDeclaredMethod(methodName);
                var parms = method.GetParameters();

                if (parms != null && parms.Length == 1)
                {
                    method.Invoke(dataContext, new[] { args.AddedItems[0] });
                }
                else
                {
                    method.Invoke(dataContext, null);
                }
            };
    }
        private void Attach(ListViewBase listView, dynamic boundSelection)
        {
            _listView = listView;
            _listView.SelectionChanged += OnListViewSelectionChanged;
            _boundSelection = boundSelection;
            _listView.SelectedItems.Clear();

            foreach (object item in _boundSelection)
            {
                if (!_listView.SelectedItems.Contains(item))
                {
                    _listView.SelectedItems.Add(item);
                }
            }

            var eventInfo =
                _boundSelection.GetType().GetDeclaredEvent("CollectionChanged");
            eventInfo.AddEventHandler(_boundSelection, _handler);
            //_boundSelection.CollectionChanged += OnBoundSelectionChanged;
        }
        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;
        }
Exemplo n.º 55
0
        public static void SmoothScrollNavigation(this Windows.UI.Xaml.Controls.ListViewBase listViewBase, int scrollAmount, ScrollNavigationDirection scrollNavigationDirection, bool disableAnimation = false)
        {
            var scrollViewer = listViewBase.FindDescendant <ScrollViewer>();

            if (scrollNavigationDirection == ScrollNavigationDirection.Left)
            {
                scrollViewer.ChangeView(scrollViewer.HorizontalOffset - scrollAmount, scrollViewer.VerticalOffset, null, disableAnimation);
            }
            else if (scrollNavigationDirection == ScrollNavigationDirection.Up)
            {
                scrollViewer.ChangeView(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset - scrollAmount, null, disableAnimation);
            }
            else if (scrollNavigationDirection == ScrollNavigationDirection.Right)
            {
                scrollViewer.ChangeView(scrollViewer.HorizontalOffset + scrollAmount, scrollViewer.VerticalOffset, null, disableAnimation);
            }
            else if (scrollNavigationDirection == ScrollNavigationDirection.Down)
            {
                scrollViewer.ChangeView(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset + scrollAmount, null, disableAnimation);
            }
        }
Exemplo n.º 56
0
        private static void OnAlternateColorPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            Windows.UI.Xaml.Controls.ListViewBase listViewBase = sender as Windows.UI.Xaml.Controls.ListViewBase;

            if (listViewBase == null)
            {
                return;
            }

            listViewBase.ContainerContentChanging -= ColorContainerContentChanging;
            listViewBase.Items.VectorChanged      -= ColorItemsVectorChanged;
            listViewBase.Unloaded -= OnListViewBaseUnloaded;

            _itemsForList[listViewBase.Items] = listViewBase;
            if (AlternateColorProperty != null)
            {
                listViewBase.ContainerContentChanging += ColorContainerContentChanging;
                listViewBase.Items.VectorChanged      += ColorItemsVectorChanged;
                listViewBase.Unloaded += OnListViewBaseUnloaded;
            }
        }
Exemplo n.º 57
0
        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;
        }
Exemplo n.º 58
0
 /// <summary>
 /// Gets the stretch <see cref="ItemContainerStretchDirection"/> associated with the specified <see cref="Windows.UI.Xaml.Controls.ListViewBase"/>
 /// </summary>
 /// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.ListViewBase"/> to get the associated <see cref="ItemContainerStretchDirection"/> from</param>
 /// <returns>The <see cref="ItemContainerStretchDirection"/> associated with the <see cref="Windows.UI.Xaml.Controls.ListViewBase"/></returns>
 public static ItemContainerStretchDirection GetItemContainerStretchDirection(Windows.UI.Xaml.Controls.ListViewBase obj)
 {
     return((ItemContainerStretchDirection)obj.GetValue(ItemContainerStretchDirectionProperty));
 }
Exemplo n.º 59
0
 async void SavedSearchesList_OnDragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args)
 {
     Debug.WriteLine("Drag Finished");
     await GlobalInfo.SaveSearches();
 }
Exemplo n.º 60
0
 /// <summary>
 /// Sets the stretch <see cref="ItemContainerStretchDirection"/> associated with the specified <see cref="Windows.UI.Xaml.Controls.ListViewBase"/>
 /// </summary>
 /// <param name="obj">The <see cref="Windows.UI.Xaml.Controls.ListViewBase"/> to associate the <see cref="ItemContainerStretchDirection"/> with</param>
 /// <param name="value">The <see cref="ItemContainerStretchDirection"/> for binding to the <see cref="Windows.UI.Xaml.Controls.ListViewBase"/></param>
 public static void SetItemContainerStretchDirection(Windows.UI.Xaml.Controls.ListViewBase obj, ItemContainerStretchDirection value)
 {
     obj.SetValue(ItemContainerStretchDirectionProperty, value);
 }