WPF TabControl with Materials Design(没有 Dragablz)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42233394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF TabControl with Materials Design (without Dragablz)
提问by Emre Can Serteli
So, I installed this "Material Design In XAML" package and it smoothly changed all my controls to be more stylish.
所以,我安装了这个“XAML 中的材料设计”包,它顺利地改变了我的所有控件,使其更加时尚。
Only the tab control seems to have an old design. I looked it up, but only thing I can find is this "Dragablz Tab Control" that you can drag and tear. Well, I don't want my users to drag or tear my tabs.
只有选项卡控件似乎具有旧设计。我查了一下,但我唯一能找到的是这个“Dragablz Tab Control”,你可以拖拽。好吧,我不希望我的用户拖拽或撕掉我的标签。
So, I'm looking for a way to either skin my tabcontrol like the other controls. Or to make Dragablz tabcontrol un-draggable and un-tearable. What can I do?
所以,我正在寻找一种方法,可以像其他控件一样为我的 tabcontrol 设置外观。或者使 Dragablz tabcontrol 不可拖动和不可撕裂。我能做什么?
回答by fruggiero
Here an example of a Dragablz tabcontrol un-draggable and un-tearable:
这是一个 Dragablz tabcontrol 不可拖动和不可撕裂的示例:
<dragablz:TabablzControl FixedHeaderCount="3">
<TabItem Header="HELLO">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Hello World</TextBlock>
</TabItem>
<TabItem Header="MATERIAL">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Material Design</TextBlock>
</TabItem>
<TabItem Header="DESIGN">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Looks Quite Nice</TextBlock>
</TabItem>
</dragablz:TabablzControl>
You can set the FixedHeaderCountattribute value as the number of tabs on your tabscontrol to make these tabs fixed. (As you can see from the source)
您可以将FixedHeaderCount属性值设置为tabscontrol 上的选项卡数量,以使这些选项卡固定。(从源码可以看出)
/// <summary>
/// Allows a the first adjacent tabs to be fixed (no dragging, and default close button will not show).
/// </summary>
public int FixedHeaderCount
{
get { return (int) GetValue(FixedHeaderCountProperty); }
set { SetValue(FixedHeaderCountProperty, value); }
}

