任何人都可以为DatePickerTextBox提供ControlTemplate吗?
我访问过MSDN。在那里,我无法找到DatePickerTextBox的ControlTemplate。但是我能够为DatePicker找到ControlTemplate。在那里我发现DatePickerTextBox有两个不同的部分,即: PART_Watermark 和 PART_ContentElement 。但我无法为DatePickerTextBox找到ControlTemplate。
答案 0 :(得分:3)
以下是 DatePickerTextBox
的默认模板:
<ControlTemplate TargetType="DatePickerTextBox">
<Grid>
<Grid.Resources>
<SolidColorBrush
x:Key="G">#FFAAAAAA</SolidColorBrush>
</Grid.Resources>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup
Name="CommonStates" />
<VisualStateGroup
Name="WatermarkStates" />
<VisualStateGroup
Name="FocusStates" />
</VisualStateManager.VisualStateGroups>
<Border
BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
CornerRadius="1,1,1,1"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
Name="Border"
Opacity="1">
<Grid
Name="WatermarkContent"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}">
<Border
BorderThickness="1,1,1,1"
BorderBrush="#FFFFFFFF"
Name="ContentElement" />
<Border
BorderThickness="1,1,1,1"
BorderBrush="#FFFFFFFF"
Name="watermark_decorator">
<ContentControl
Padding="2,2,2,2"
Name="PART_Watermark"
Opacity="0"
IsHitTestVisible="False"
Focusable="False" />
</Border>
<ScrollViewer
HorizontalContentAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding Control.VerticalContentAlignment}"
Name="PART_ContentHost"
Margin="0,0,0,0" />
<Border
CornerRadius="1,1,1,1"
BorderBrush="#FF45D6FA"
Name="FocusVisual"
Opacity="0"
IsHitTestVisible="False" />
</Grid>
</Border>
</Grid>
</ControlTemplate>