WPF TabControl-添加新的选项卡按钮(+) [英] WPF TabControl - Add New Tab Button (+)

查看:1350
本文介绍了WPF TabControl-添加新的选项卡按钮(+)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

* http://stackoverflow.com/questions/3468866/wpf-tabcontrol-add-new-tab-button*

的副本

在标签控件的标签栏中所有标签项末尾添加"+"按钮标签的正确方法是什么.

  1. 它应该与多个选项卡标题行一起正常工作.
  2. 它应该在所有选项卡项的末尾
  3. 选项卡循环应正确运行(Alt + Tab),即应跳过+选项卡.
  4. 我不必修改要绑定到的源集合.即控件应该是可重用的.
  5. 解决方案应与MVVM一起使用

为更加精确,该按钮应完全显示为其他最后一个标签,而不是在所有标签条行右侧的单独按钮.

我只是在寻找执行此操作的一般方法.

Google给出了许多这样的示例,但是如果您深入一点,它们都不满足上述所有四个要点.

任何帮助都将不胜感激.

N

解决方案

Nishant,

这是我的方法:

1.在顶部图像上几乎有一个多余的TabItem,其中只有加号(您的TabControl至少有一个TabItem是带有加号或添加标签"的)

2.单击TabItem标头(即,将选择更改为此添加选项卡" TabItem)时,创建一个新的TabItem,将其添加到此添加选项卡" TabItem之前,然后切换到该选择. /p>

3.您可以将IsTabStop设置为false也许可以得到想要的效果?

 

没有这样做,但是看起来非常平易近人.


*Copy of http://stackoverflow.com/questions/3468866/wpf-tabcontrol-add-new-tab-button*

What is the proper way of adding a '+' button tab at the end of all the tab items in the tab strip of a tab control.

  1. It should work correctly with multiple tab header rows.
  2. It should be at the end of all tab items
  3. Tab cycling should work correctly (Alt+Tab) ie the + tab should be skipped.
  4. I shouldn't have to modify the source collection I am binding to. ie the control should be reuseable.
  5. Solution should work with MVVM

EDIT: To be more precise, the button should appear exactly as an additional last tab and not as a separate button somewhere on the right of all tab strip rows.

I am just looking for the general approach to doing this.

Google throws many examples of this, but if you dig a little deep none of them satisfy all the above four points.

Any help greatly appreciated.

N

解决方案

Nishant,

Here is my approach:

1.Have an extra TabItem that is empty with just the plus sign as you almost have on the top image (your TabControl will have at least one TabItem that is the one with plus sign or "Add Tab"

2.when you click on TabItem Header (ie when the selection is changed to this 'Add Tab' TabItem), create a new TabItem, add it just before this 'Add Tab' TabItem, and switch to that selection.

3. You can set the IsTabStop to false maybe to get the desired effect you want ?

 

Not done this, but seems very much approachable.


这篇关于WPF TabControl-添加新的选项卡按钮(+)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆