按Tab键和Shift + Tab时自定义文本框不会聚焦

时间:2015-08-04 13:15:22

标签: c# wpf xaml focus custom-controls

我有CustomTextBox控件它附带Place HolderText。 控件的样式就像这样

<Style TargetType="{x:Type controls:WaterMarkTextBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type controls:WaterMarkTextBox}">
                <Grid x:Name="PART_GridControl"
                      Height="{TemplateBinding Height}"
                      Width="{TemplateBinding Width}">
                    <TextBlock x:Name="PART_PlaceHolderTextBlock"                                   
                               VerticalAlignment="Center"
                               Margin="20,0,10,0"/>
                    <TextBox  x:Name="PART_PlaceHolderTextBox"
                              Background="Transparent"
                              VerticalContentAlignment="Center"
                              FontSize="{TemplateBinding FontSize}"
                              FontFamily="{TemplateBinding FontFamily}"
                              FontWeight="{TemplateBinding FontWeight}"
                              Padding="20,0,150,0" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

但是当我按下标签时,它不会聚焦。请帮我解决这个问题。提前致谢。

0 个答案:

没有答案
相关问题