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


C# ListBoxItem.SetCurrentValueInternal方法代码示例

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


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

示例1: MakeToggleSelection

        private void MakeToggleSelection(ListBoxItem item)
        {
            bool select = !item.IsSelected;

            item.SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.Box(select));

            UpdateAnchorAndActionItem(ItemInfoFromContainer(item));
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:ListBox.cs

示例2: NotifyListItemClicked

        internal void NotifyListItemClicked(ListBoxItem item, MouseButton mouseButton)
        {
            // When a ListBoxItem is left clicked, we should take capture
            // so we can auto scroll through the list.
            if (mouseButton == MouseButton.Left && Mouse.Captured != this)
            {
                Mouse.Capture(this, CaptureMode.SubTree);
                SetInitialMousePosition(); // Start tracking mouse movement
            }

            switch (SelectionMode)
            {
                case SelectionMode.Single:
                    {
                        if (!item.IsSelected)
                        {
                            item.SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.TrueBox);
                        }
                        else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                        {
                            item.SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.FalseBox);
                        }

                        UpdateAnchorAndActionItem(ItemInfoFromContainer(item));
                    }
                    break;

                case SelectionMode.Multiple:
                    MakeToggleSelection(item);
                    break;

                case SelectionMode.Extended:
                    // Extended selection works only with Left mouse button
                    if (mouseButton == MouseButton.Left)
                    {
                        if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == (ModifierKeys.Control | ModifierKeys.Shift))
                        {
                            MakeAnchorSelection(item, false);
                        }
                        else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                        {
                            MakeToggleSelection(item);
                        }
                        else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                        {
                            MakeAnchorSelection(item, true);
                        }
                        else
                        {
                            MakeSingleSelection(item);
                        }
                    }
                    else if (mouseButton == MouseButton.Right) // Right mouse button
                    {
                        // Shift or Control combination should not trigger any action
                        // If only Right mouse button is pressed we should move the anchor
                        // and select the item only if element under the mouse is not selected
                        if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == 0)
                        {
                            if (item.IsSelected)
                                UpdateAnchorAndActionItem(ItemInfoFromContainer(item));
                            else
                                MakeSingleSelection(item);
                        }
                    }

                    break;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:69,代码来源:ListBox.cs


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