-
0 votesanswersviews
修改TextBox ControlTemplate以限制滚动,属性设置在运行时不正确
I'm having problems customizing the ControlTemplate for a TextBox . 我们的想法是在尽可能少的用户交互的情况下,在衬纸上自动打印文本,同时尽可能保持文本长度,字体大小等方面的灵活性 . 为此,一个设置是相对于打印线的文本高度(它在纸上出现的线的接近/远处) . 由于更改TextBox LineHeight 会在文本下方添加空格而... -
1 votesanswersviews
ControlTemplate中的DataTrigger不会更新
我有一个ListBox绑定到CustomerViewModel对象列表,每个对象都有两个依赖属性: 名称(字符串) 描述(字符串) IsVisible(bool) (默认情况下,IsVisible属性为True,并通过CustomerViewModel上的ToggleVisibility命令反转) 我想在边框控件的右边显示名称和描述,当IsVisible属性为True时显示透明背景,当Fals... -
0 votesanswersviews
wpf:将样式DataTrigger更改为ControlTemplate DataTrigger
我有一个用于ToggleButton的大型ControlTemplate . 我试图添加一个没有成功的数据触发器 . 然而,我已经使用样式添加它,如下所示: <Window.Resources> <Style x:Key="toggleBtnStyle" TargetType="{x:Type ToggleButton}"> ... -
0 votesanswersviews
在ControlTemplate DataTrigger中更改按钮背景
我想为"color swatch"按钮定义一个WPF ControlTemplate . 基本上,我希望能够使用这样的模板: <Button Template="{StaticResource SwatchButtonTemplate}" Background="{Binding ActiveColor}"> Active... -
0 votesanswersviews
使用DataTrigger按钮ControlTemplate中的样式边框
我有以下元素: <Button Click="btn_Click" Name="aName"> <Button.Template> <ControlTemplate TargetType="Button"> <Border Name="tm... -
1 votesanswersviews
ToggleButton Style仅适用于最后一个ToggleButton
我正在尝试自定义我的ToggleButtons,以便在检查时他们用绿色表示“是”,如果没有选中,则用红色表示“否” . 我创建了以下样式,它位于我的样式资源字典中 . <!-- ToggleButtons --> <Style x:Key="YesNoToggleStyle" TargetType="ToggleButton">... -
2 votesanswersviews
使用其名称从Style BasedOn访问样式ControlTemplate中的元素
我有一个Style,用于Button的ButtonStyle,里面有VisualStates,Properties和Triggers . 我有另一种风格的BasedOn ButtonStyle . 我需要在BasedOn样式中访问名为“OnhoverGrid”的元素,以更改其属性 . ButtonStyle中的ControlTemplate包含许多元素和setter . 我无法使用从现有Cont... -
7 votesanswersviews
是否可以像在WPF中扩展Style一样扩展ControlTemplate?
所以问题是我有一个主要的ControlTemplate,它定义了我们正在设计的新按钮外观的最基本的东西 . 但是我想为这个按钮做3个其他的控制模板,所以我们可以设置不同的颜色;但我不想复制粘贴主ControlTemplate并更改那里的颜色,而是我想从那里“继承”(与Style中的BasedOn属性一样)并更改继承的ControlTemplate中的颜色 . 这可能吗? 谢谢! -
24 votesanswersviews
WPF ControlTemplate:如何为TemplateBinding提供默认值?
我正在编写一个WPF控件,它是Button的子类 . 然后我在Themes \ generic.xaml中提供了一个默认样式,它看起来像这样(简化): <Style TargetType="{x:Type WPFControls:MyButton}"> <Setter Property="Template"> ... -
32 votesanswersviews
我在哪里可以找到默认的WPF控件模板?
按照这个MSDN链接, 无法仅替换控件的部分可视树;若要更改控件的可视树,必须将控件的Template属性设置为新的完整ControlTemplate . 我试图禁用GridViewColumnHeader的点击行为(我需要删除原始控件模板中的一些触发器),但我无法找到本机“ColumnHeaderContainerStyle” . 我发现的所有人似乎已经做了一些定制,很难获得原始的外观和感觉... -
0 votesanswersviews
绑定到自定义ControlTemplate中的属性
我有一个自定义数据样式网格,我在一个单独的资源文件中定义 . 在这种风格中,我重写ControlTemplate来改变它的外观 . 然后我有自己的CustomDataGrid控件,该控件派生自UserControl并使用资源文件中的样式 . 我需要能够让垂直滚动条具有用户定义的宽度 . 我知道如何通过硬编码值来更改滚动条宽度 . 我不能做的是make,以便在我的自定义控件中我可以设置滚动条宽度 .... -
0 votesanswersviews
在使用ControlTemplates定义的程序集中定义的自定义控件
我创建了一个带有自定义控件的库,以简化我的同事的一些开发 . 然后我创建了一个模板,我想让他们有机会修改默认模板等等 . 经过一些研究,我发现了一些关于Themes,Generic.xaml和ThemeInfo属性的信息,但有些东西不起作用 . 所以我的最后一次尝试: - AssemblyInfo.cs中带有Theme属性的控件库: [assembly: ThemeInfo( ResourceD... -
0 votesanswersviews
在代码中创建controltemplate,如何在绑定中指定转换器
我检查了这些答案,但没有人得到我正在寻找的信息:How to setup a WPF datatemplate in code for a treeview?How to set Control Template in code?Create ControlTemplate programmatically in WPF 这是我的代码的要点: DataGridTextColumn col = ne... -
1 votesanswersviews
如何通过代码隐藏访问ControlTemplate的命名元素?
我想在代码隐藏中访问另一个元素正在使用的原始控件模板中的一个命名元素 . 这是XAML代码的一个例子(显然原始代码更复杂,或者我只是在XAML中执行此操作): <Window x:Class="Temp.MainWindow" Title="MainWindow"> <Window.Resources> <... -
12 votesanswersviews
将重点放在ControlTemplate中的控件上(第2部分)
我'm stumped on what must surely be one of the most common WPF requirements. I'已阅读this question但我的解决方案的实施不起作用 . 这是无视控件的标记: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xam... -
0 votesanswersviews
WPF设置焦点以控制控件模板内
我有以下ControlTemplate: <ControlTemplate TargetType="dxe:TextEdit" x:Key="TextEditMultiStyle"> <Border x:Name="border" BorderBrush="#054c74" BorderThi... -
3 votesanswersviews
故事板不从ControlTemplate DataTrigger执行
我有一个ToggleButton,我点击它弹出FlowDocumentReader作为Adorner . 此FlowDocument是ControlTemplate的一部分,带有DataTrigger以显示/隐藏元素 . 使用以下触发器一切正常 . 我使用DataTrigger和一些Setter,当我检查我的ToggleButton时,我的元素正确显示我提供的高度和宽度: <ControlT... -
2 votesanswersviews
如何将自定义Controltemplate设置为整个应用程序的默认值?
我决定尝试自定义Menu和MenuItem的默认控件模板的许多方面 . 在Visual Studio中,我选择了我的菜单,在属性面板中找到了“模板”,然后选择了“转换为新资源...” . 我为MenuItem做了同样的事情 . 然后,为了测试,我将MenuItem SubMenuBorder颜色更改为红色 . 此时,我有一个包含两个ControlTemplates的资源字典,以及一个如下所示的Me...