如何设置 DatePicker 的样式?
我下载了 WPFToolkit 源代码,因为我想覆盖 DatePicker 的默认通用模板。 例如,我想覆盖这个 TextBox:
<primitives:DatePickerTextBox x:Name="PART_TextBox"
Grid.Row="0" Grid.Column="0"
Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" />
这意味着在我的项目中编写这个:
<Style TargetType="{x:Type toolkit:DatePickerTextBox}">
<Setter Property="Text" Value="Bitte wählen" />
<Setter Property="MinHeight" Value="20" />
效果很好。 但是如果我想将 VerticalContentAlignment="Stretch"
更改为 VerticalContentAlignment="Center"
该怎么办? 默认样式始终会覆盖它。 感谢您的回复!
I downloaded a WPFToolkit source, because I wanted to override the default generic template of a DatePicker. For example, I wanted to override this TextBox:
<primitives:DatePickerTextBox x:Name="PART_TextBox"
Grid.Row="0" Grid.Column="0"
Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" />
That means that writing this in my project :
<Style TargetType="{x:Type toolkit:DatePickerTextBox}">
<Setter Property="Text" Value="Bitte wählen" />
<Setter Property="MinHeight" Value="20" />
works perfectly.
But what if I want to change VerticalContentAlignment="Stretch"
to VerticalContentAlignment="Center"
?? The default style always overrides it.
Thanks for response!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我下载了这些控件的源代码,直接从 Microsoft 获取此样式并将其应用到我的 DatePicker 上。 有效!
特别看看这个:
这是我设置内部文本框样式的地方。
Ok I downloaded a Source of those controls, took this Style directly from Microsoft and applied it on my DatePicker. It worked!
Look especially at this:
This is where i style my inner TextBox.