应用控制模板后,XAML文本框变为不可编辑

时间:2013-02-04 07:47:35

标签: xaml winrt-xaml

我想要我的Windows商店应用程序(C ++)的圆边文本框。我已经将控制模板应用到XAML文本框以使其圆润边缘。但是在运行应用程序后我得到圆边但我无法编辑这个TextBox。 我是XAML的新手。 Plz帮助我找出此代码中缺少的内容,使其可编辑。

这是使它成为圆边后的代码。

<TextBox HorizontalAlignment="Left" Margin="51,202,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="23" Width="246" Background="White" BorderBrush="#FF00AAA6" IsReadOnly="False">
        <TextBox.Resources>
            <ControlTemplate x:Key="TextBoxControlTemplate1" TargetType="TextBox">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="PointerOver"/>
                            <VisualState x:Name="Focused"/>
                            <VisualState x:Name="Disabled"/>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ButtonStates">
                            <VisualState x:Name="ButtonCollapsed"/>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Border BorderThickness="1" Padding="2" CornerRadius="3" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"/>
                </Grid>
            </ControlTemplate>
        </TextBox.Resources>
        <TextBox.Template>
            <StaticResource ResourceKey="TextBoxControlTemplate1"/>
        </TextBox.Template>
    </TextBox>           

1 个答案:

答案 0 :(得分:0)

在示例代码中,ControlTemplate不包含导致缺少可编辑输入元素的ContentElement。

使用下面的链接检查TextBox的真实样式,只更改圆角视觉的相关边框“CornerRadius”属性

TextBox Style