簡體   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