- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 WPF 开发 (.net 3.5 sp1) 中遇到了一个恼人的问题,我一直在处理这个问题,它涉及在我的界面上显示一些选项卡(并旋转)。
我一直在使用普通 Aero 主题的 Windows 7 机器上进行开发,标签看起来不错
当我们部署给客户时,他们的机器设置为“Windows Classic”主题,选项卡显示为
因此它们都被“压扁”并且不显示文本。如果我将我的机器切换到 Windows Classic,那么我就可以重现。我查看了 WPF Inspector 的界面,可以看到一些不应该存在的填充值
如果我使用 WPF Inspector 将填充值更改为 0,那么选项卡将再次开始正确显示!我已经在我的模板上将填充设置为 0,但它似乎没有任何影响
<TabControl TabStripPlacement="Left"
SelectedIndex="{Binding CurrentTabIndex}"
ItemsSource="{Binding CurrentPassengers}">
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Padding"
Value="0" />
<Setter Property="Margin"
Value="0" />
<Setter Property="Width"
Value="26.5" />
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<ContentPresenter Content="{Binding NameInGDSFormat}">
<ContentPresenter.LayoutTransform>
<RotateTransform Angle="-90" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Resources>
<TabControl.ContentTemplate>
<!-- Lots of stuff in here for the Content Template -->
</TabControl.ContentTemplate>
</TabControl>
我已经尝试设置各种模板,填充各种元素,但似乎没有任何改变 - 那么有人知道我该如何解决这个问题吗?
编辑:如果我删除设置的“宽度”,那么它实际上会在 Windows Classic 中显示 - 但选项卡非常宽。
最佳答案
好的 - 所以最后我不得不创建一个全新的 ControlTemplate 来解决这个问题:)
基本上我在原始的 Classic ControlTemplate 中找到了以下内容
<ContentPresenter RecognizesAccessKey="True"
Content="{TemplateBindingReaderedContentControl.Header}"
ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
ContentStringFormat="{TemplateBinding HeaderedContentControl.HeaderStringFormat}"
ContentSource="Header"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="{TemplateBinding Control.Padding}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
所以有人认为将 Margin 绑定(bind)到 Padding 是个好主意,然后当您将 Tabs 放在左侧(或右侧)时,进一步添加模板
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelected">
<Condition.Value>
<s:Boolean>True</s:Boolean>
</Condition.Value>
</Condition>
<Condition Property="TabItem.TabStripPlacement" Value="{x:Static Dock.Left}"/>
</MultiTrigger.Conditions>
<Setter Property="Control.Padding">
<Setter.Value>
<Thickness>11,2,14,2</Thickness>
</Setter.Value>
</Setter>
<Setter Property="FrameworkElement.Margin">
<Setter.Value>
<Thickness>-2,-2,-2,-2</Thickness>
</Setter.Value>
</Setter>
</MultiTrigger>
因此他们将 Padding 设置为 11,2,14,2(我在 WPF Inspector 中看到的值)。
所以我不得不覆盖模板,将边距设置为合理的值,然后将填充设置为更现实的值,以处理内容呈现器旋转 270 度的情况:)
希望这对遇到此问题的其他人有所帮助!!
关于c# - Windows 经典主题上的 WPF Tabcontrol TabItem 显示问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30058298/
我正在构建一个 LOB 应用程序,它有一个主要部分和一个包含各种 TabItems 的 TabControl。点击保存的想法是突出显示任何错误的字段,并且错误的第一个字段获得焦点。 如果第一个也是唯一
我将 xaml 中 tabitem 的背景颜色设置为红色,但是当我运行它并将鼠标悬停在它上面或选择它时,它会变回默认的灰色外观。仅当选择其他选项卡时,它才会正确显示。我怎样才能让它一直保持红色。谢谢!
如何为 tabitem 标题和该 tabitem 的内容设置不同的字体? 最佳答案 就像 WPF 中的任何东西一样,有很多方法。在不知道你到底想做什么的情况下,这里有一个“例如”(我不建议使用这种字体
之前选择的tabitem和选择的tabitem的动画开始工作正常,然后就不能正常工作了。 在我看来,代码应该可以正常工作。我不知道为什么现在动画不正确。 主窗口.xaml:
我有一个 Silverlight 应用程序,它有一个带有多个 TabItem 的 TabControl。当用户选择选项卡项时,我想将焦点设置到该选项卡项中的特定控件。我该怎么做? 我尝试为 TabCo
我在 TabControl 上有一个相当奇怪的行为,它的 TabItems 都折叠了:第一个 TabItem 的内容仍然可见(但标题不是)。 TabControl 及其 TabItems 设置如下:
下面是我的代码,当按下按钮时,我将根据我的情况使用 item1.setcontrol 更改 item1 列表。复合不刷新,但是当我单击 Item2 选项卡并返回 Item1 选项卡时...列表更新取决
这个问题有没有什么好的解决办法。 我已经设置了 tabitem.visibility=hidden 但这个 tabitem 中的内容仍然可见。我想隐藏tabitems的所有内容。 我确实搜索了一个解决
例如,使用 WPF 在选项卡控件的最左上角定位三个 tabitem 和在最右上角定位一个 tabitem 的正确方法是什么? 我尝试通过更改边距将第四个 tabitem 向右移动,但这并没有产生好的结
我正在尝试设置 TabControl 的样式,并且已经完成了 75% 的设置,但是我在设置实际 TabItems 的样式时遇到了困难: 我想要实现的是删除默认的 ContentPresenter 以便
我有一个 TabControl,其中有许多 TabItems 绑定(bind)到一个 ViewModel,该 ViewModel 具有每个 TabItem 的可见性的属性。 所有 Tab
我有一个 NSTabViewController,它有两个 NSTabViewItem。我想禁用第二个选项卡。 class MainTabViewController: NSTabViewContro
在这里,我有一个使用 Prism 6 Toolkit 的功能性 CloseTabAction,如下所示: class CloseTabAction : TriggerAction { prot
我有一个动态创建选项卡的 WPF 应用程序,现在我希望每个选项卡项都必须包含扩展器和用户控件,并且在运行时为扩展器和用户控件设置数据上下文 strong>,所以如果我在Style中定义tabitem的
我有一个问题。在我的 WPF 应用程序中,如果我用鼠标中键按下一个 tabItem,这个 tabItem 应该关闭。就像在 FireFox 中一样。但是我尝试使用 MVVM 来执行此操作,并且我需要使
您好,我正在使用 TabControl 制作 session 系统,私有(private)聊天将在新的 TabItem 中。我正在使用此代码来介绍一个新成员私下聊天: TabItem ti = new
所以我得到了一个带有一些 Tabitems 和一些按钮的 TabControl。 当我按下这些按钮时,会改变 TabStrip 的位置。 一切正常。我现在要做的是, 当我按下按钮 Right90 将标
是否可以在 TabControl 的 TabItem 中打开另一个 Window? 我想这样做的原因是,如果我的 TabControl 中有 5 个 TabItem,我正在编写所有这些 TabItem
我有一个TabControl 控件 在后面的代码中,我向 TabControl 动态添加了一些选项卡,如下所示: foreach (Village vill in Villages) {
如何向 wpf tabitem 添加一个上下文菜单,该菜单仅在我单击 tabitem 标题而不是内容时出现? 我还需要在 .cs 中动态创建 tabitems,因此在 .xaml 中静态执行此操作将不
我是一名优秀的程序员,十分优秀!