我在哪里可以找到DatePickerTextBox的ControlTemplate?

时间:2014-08-31 14:46:22

标签: c# .net wpf xaml

任何人都可以为DatePickerTextBox提供ControlTemplate吗?

我访问过MSDN。在那里,我无法找到DatePickerTextBox的ControlTemplate。但是我能够为DatePicker找到ControlTemplate。在那里我发现DatePickerTextBox有两个不同的部分,即: PART_Watermark PART_ContentElement 。但我无法为DatePickerTextBox找到ControlTemplate。

1 个答案:

答案 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>