繁体   English   中英

WPF使用文本框自定义样式导致无法将文本插入文本框

[英]WPF Using textbox custom style causing not to be able to insert text to the textbox

我为TextBox控件编写了自定义样式,现在当我使用它时,在运行时无法在TextBox键入文本。 这是我的风格:

<Style x:Key="TextBoxStyle"
       TargetType="TextBox" >
        <Setter Property="Height" Value="41"></Setter>
        <Setter Property="Width" Value="114"></Setter>
        <Setter Property="Foreground" Value="#FFDDDDDD"></Setter>
        <Setter Property="Focusable" Value="False"></Setter>
        <Setter Property="FontFamily" Value="Verdana"></Setter>
        <Setter Property="FontSize" Value="18"></Setter>
        <Setter Property="FontWeight" Value="Regular"></Setter>
        <Setter Property="TextAlignment" Value="Center"></Setter>
        <Setter Property="IsReadOnly" Value="False"></Setter>
        <Setter Property="BorderBrush" Value="{x:Null}"></Setter>
        <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
        <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
        <Setter Property="Background">
            <Setter.Value>
                <ImageBrush ImageSource="/App;component/Images/BarsForms/precent_bg.png" Stretch="UniformToFill" TileMode="None" />    
            </Setter.Value>
        </Setter>
    </Style>
<Setter Property="Focusable" Value="False"></Setter>

在您的样式中将Focusable设置为false可以防止光标选择TextBox和设置光标键入的功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM