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


C# ListBox.ScrollIntoViewFix方法代码示例

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


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

示例1: addItems

        public void addItems(ListBox src, ListBox target, bool IsInsert = false)
        {
            try
            {
                if (src == null || target == null) return;

                int LastIndex = -1;
                foreach (object info in src.SelectedItems)
                {
                    if (IsEnableAdd(target, info) == true)
                    {
                        if (IsInsert == true && target.SelectedItem != null)
                        {
                            target.Items.Insert(target.SelectedIndex + 1, info);
                            target.SelectedIndex += 1;
                            LastIndex = target.SelectedIndex;
                        }
                        else
                        {
                            target.Items.Add(info);
                            LastIndex = target.Items.Count - 1;
                        }
                    }
                }
                if (target.Items.Count != 0 && LastIndex >=0)
                {
                    target.SelectedIndex = LastIndex;
                    target.ScrollIntoViewFix(LastIndex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
开发者ID:xceza7,项目名称:EDCB,代码行数:35,代码来源:BoxExchangeEditor.cs

示例2: move_item

        /// <summary>アイテムを移動</summary>
        public void move_item(ListBox target, int direction)
        {
            try
            {
                if (target == null || target.SelectedItem == null) return;

                object temp = target.SelectedItem;
                int newIndex = ((target.SelectedIndex + direction) % target.Items.Count + target.Items.Count) % target.Items.Count;
                target.Items.RemoveAt(target.SelectedIndex);
                target.Items.Insert(newIndex, temp);
                target.SelectedIndex = newIndex;
                target.ScrollIntoViewFix(newIndex);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
开发者ID:xceza7,项目名称:EDCB,代码行数:19,代码来源:BoxExchangeEditor.cs

示例3: getBoxKeyEnableHandler

 private KeyEventHandler getBoxKeyEnableHandler(ListBox box, KeyEventHandler handler, bool src)
 {
     return new KeyEventHandler((sender, e) =>
     {
         if (Keyboard.Modifiers == ModifierKeys.None)
         {
             switch (e.Key)
             {
                 case Key.Escape:
                     if (box.SelectedItem != null)
                     {
                         box.UnselectAll();
                         e.Handled = true;
                     }
                     break;
                 case Key.Enter:
                     if (src == true)
                     {
                         handler(sender, e);
                         //一つ下へ移動する。ただし、カーソル位置は正しく動かない。
                         int pos = box.SelectedIndex + 1;
                         box.SelectedIndex = Math.Max(0, Math.Min(pos, box.Items.Count - 1));
                         box.ScrollIntoViewFix(box.SelectedIndex);
                         e.Handled = true;
                     }
                     break;
                 case Key.Delete:
                     if (src == false)
                     {
                         handler(sender, e);
                         e.Handled = true;
                     }
                     break;
             }
         }
     });
 }
开发者ID:xceza7,项目名称:EDCB,代码行数:37,代码来源:BoxExchangeEditor.cs

示例4: deleteItems

        public void deleteItems(ListBox target)
        {
            try
            {
                if (target == null) return;

                int newSelectedIndex = -1;
                while (target.SelectedIndex >= 0)
                {
                    newSelectedIndex = target.SelectedIndex;
                    target.Items.RemoveAt(newSelectedIndex);
                }

                if (target.Items.Count != 0)
                {
                    target.Items.Refresh();
                    newSelectedIndex = (newSelectedIndex == target.Items.Count ? newSelectedIndex - 1 : newSelectedIndex);
                    target.SelectedIndex = newSelectedIndex;
                    target.ScrollIntoViewFix(newSelectedIndex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
开发者ID:xceza7,项目名称:EDCB,代码行数:26,代码来源:BoxExchangeEditor.cs


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