当前位置: 首页>>代码示例>>C#>>正文


C# ItemsControl.ContainerFromElement方法代码示例

本文整理汇总了C#中System.Windows.Controls.ItemsControl.ContainerFromElement方法的典型用法代码示例。如果您正苦于以下问题:C# ItemsControl.ContainerFromElement方法的具体用法?C# ItemsControl.ContainerFromElement怎么用?C# ItemsControl.ContainerFromElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ItemsControl的用法示例。


在下文中一共展示了ItemsControl.ContainerFromElement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DragSource_PreviewMouseLeftButtonDown

        private void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _sourceItemsControl = (ItemsControl) sender;
            var visual = e.OriginalSource as Visual;

            _topWindow = Window.GetWindow(_sourceItemsControl);
            _initialMousePosition = e.GetPosition(_topWindow);

            _sourceItemContainer = _sourceItemsControl.ContainerFromElement(visual) as FrameworkElement;
            if (_sourceItemContainer != null)
            {
                _draggedData = _sourceItemContainer.DataContext;
            }
        }
开发者ID:Orange637,项目名称:WpfStudy,代码行数:14,代码来源:DragDropService.cs

示例2: ContainerFromElement

		public static DependencyObject ContainerFromElement (ItemsControl itemsControl, DependencyObject element)
		{
			return itemsControl.ContainerFromElement (element);
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:4,代码来源:ItemsControl.cs

示例3: DragSource_PreviewMouseLeftButtonDown

        // DragSource
        private void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.sourceItemsControl = (ItemsControl)sender;
            Visual visual = e.OriginalSource as Visual;

            this.topWindow = Window.GetWindow(this.sourceItemsControl);
            this.initialMousePosition = e.GetPosition(this.topWindow);

            this.sourceItemContainer = sourceItemsControl.ContainerFromElement(visual) as FrameworkElement;
            if (this.sourceItemContainer != null)
            {
                //this.draggedData = this.sourceItemContainer.DataContext;
                this.draggedData = this.sourceItemContainer; // TODO changed
            }
        }
开发者ID:rabbicse,项目名称:WPF-SBMS,代码行数:16,代码来源:DragDropHelper.cs

示例4: DragSource_PreviewTouchDown

        // DragSource Touch
        private void DragSource_PreviewTouchDown(object sender, TouchEventArgs e)
        {
            if (!_ignoreNextTouchDownEvent)
            {
                this.sourceItemsControl = (ItemsControl)sender;
                Visual visual = e.OriginalSource as Visual;

                this.topWindow = Window.GetWindow(this.sourceItemsControl);
                this.initialMousePosition = e.GetTouchPoint(this.topWindow).Position;

                this.sourceItemContainer = sourceItemsControl.ContainerFromElement(visual) as FrameworkElement;
                if (this.sourceItemContainer != null)
                {
                    this.draggedData = this.sourceItemContainer.DataContext;

                    //Console.WriteLine("preview mouse down, initiate drag");
                }
            }
            else
            {
                _ignoreNextTouchDownEvent = false;
            }
        }
开发者ID:roederf,项目名称:wpfReferenceApp,代码行数:24,代码来源:DragDropHelper.cs

示例5: DragSource_PreviewMouseLeftButtonDown

        // DragSource
        private void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.sourceItemsControl = (ItemsControl)sender;
            DependencyObject visual = e.OriginalSource as DependencyObject;
            if (visual == null)
                return;

            this.sourceItemContainer = sourceItemsControl.ContainerFromElement(visual) as FrameworkElement;
            if (this.sourceItemContainer == null)
                return;

            bool? canDrag = sourceItemContainer.GetValue(DragDrop.DragDropHelper.IsDragAllowedProperty) as bool?;
            if (canDrag.HasValue && !canDrag.Value)
                return;

            this.draggedData = this.sourceItemContainer.DataContext;
            this.topWindow = Window.GetWindow(this.sourceItemsControl);
            this.initialMousePosition = e.GetPosition(this.topWindow);
        }
开发者ID:klot-git,项目名称:scrum-factory,代码行数:20,代码来源:DragDropHelper.cs

示例6: dragSource_PreviewMouseLeftButtonDown

        private void dragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            sourceItemsControl = (ItemsControl)sender;
            Visual visual = e.OriginalSource as Visual;

            topWindow = Window.GetWindow(sourceItemsControl);

            sourceItemContainer = sourceItemsControl.ContainerFromElement(visual) as FrameworkElement;
            if(sourceItemContainer!=null)
            {
                draggedData = sourceItemContainer.DataContext;
            }
        }
开发者ID:ZuTa,项目名称:StudyingController,代码行数:13,代码来源:DragDropHelper.cs

示例7: DragSource_PreviewMouseDoubleClick

        // DragSource
        private void DragSource_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            this._sourceItemsControl = (ItemsControl)sender;
            var visual = e.OriginalSource as Visual;

            this._sourceItemContainer = _sourceItemsControl.ContainerFromElement(visual) as FrameworkElement;
            if (this._sourceItemContainer != null)
            {
                this._draggedData = this._sourceItemContainer.DataContext;
            }
            int indexRemoved = RemoveItemFromItemsControl(this._sourceItemsControl, this._draggedData);
            Type draggedType = this._draggedData.GetType();
            object newitem = Activator.CreateInstance(draggedType);
            InsertItemInItemsControl(this._sourceItemsControl, newitem, indexRemoved);
            e.Handled = true;
        }
开发者ID:GorelH,项目名称:Schedule-1,代码行数:17,代码来源:DragDropHelper.cs

示例8: GetGeneratedParentElement

 private DependencyObject GetGeneratedParentElement(ItemsControl itemsControl)
 {
     return itemsControl.ContainerFromElement(this);
 }
开发者ID:postsharp,项目名称:VisualDesigner,代码行数:4,代码来源:EditableTextBlock.cs

示例9: DecideDropTarget

        private int DecideDropTarget(DragEventArgs e, ItemsControl targetItemsControl)
        {
            int targetItemsControlCount = targetItemsControl.Items.Count;
            DependencyObject targetItemContainer;
            int insertionIndex = -1;

            if (targetItemsControlCount > 0)
            {
                targetItemContainer = targetItemsControl.ContainerFromElement((DependencyObject)e.OriginalSource) as FrameworkElement;

                if (targetItemContainer != null)
                {
                     insertionIndex = targetItemsControl.ItemContainerGenerator.IndexFromContainer(targetItemContainer);
                }
                else
                {
                    targetItemContainer = targetItemsControl.ItemContainerGenerator.ContainerFromIndex(targetItemsControlCount - 1) as FrameworkElement;
                    insertionIndex = targetItemsControlCount;
                }
            }
            else
            {
                targetItemContainer = null;
                insertionIndex = 0;
            }

            return insertionIndex;
        }
开发者ID:jscott7,项目名称:SuperMarketPlanner,代码行数:28,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Controls.ItemsControl.ContainerFromElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。