简体   繁体   English

在WPF中以编程方式关闭TabItem

[英]Programmatically close TabItem in WPF

How the hell do you programmatically close a TabItem in a Windows 8 WPF Desktop TabControl? 您如何以编程方式关闭Windows 8 WPF桌面TabControl中的TabItem?

There are no options in Intellisense, and the only things that appear in search results are custom implementations of either the TabControl or the TabItem. Intellisense中没有任何选项,搜索结果中显示的唯一内容是TabControl或TabItem的自定义实现。

Why can't we just do something like tabControl.SelectedItem.Close(); 为什么我们不能只做tabControl.SelectedItem.Close();类的事情tabControl.SelectedItem.Close(); ?

I think that closing is the same as removing TabItem from TabControl 我认为关闭与从TabControl中删除TabItem相同

Edit: For Ex: 编辑:对于例如:

tabControl1.Items.RemoveAt(tabControl1.SelectedIndex);

You cannot close it. 您无法关闭它。 TabItem is not closeable. TabItem无法关闭。 You can just hide it: 您可以将其隐藏:

tabControl.SelectedItem.Visibility = System.Windows.Visibility.Collapsed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM