更改我的文本框的背景颜色 [英] Change the background color of my textbox

查看:79
本文介绍了更改我的文本框的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我有一个wp7应用程序,它使用深黑色和红色渐变图像作为背景,并且在黑暗主题中一切正常,但是当我更改为明亮主题时,我的文本框和其他表单元素就会消失.我已将Background ="White"分配给到 文本框,看起来不错,但是当我点击该文本框以调出键盘时,该文本框再次变黑.无论选择什么主题,有什么办法可以使我的文本框始终显示?

I have a wp7 app that is using a dark black and red gradient image as the backgroound and everything works fine in the dark theme but when I change to the light theme, my textboxes and other form elements disappear. I've assigned a Background="White" to the textbox and that appears ok but when I tap on the textbox to bring up the keyboard, the textbox goes black again. Is there any way of having my textboxes always show up regardless of what theme is selected?

这是代码...这是底部的4个文本块和文本框不配合.

Here is the code...it's the 4 textblocks and textboxes at the bottom that are not co-operating.

谢谢

<Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="../team_generator_bg.png" Stretch="Fill" AlignmentX="Left" AlignmentY="Top"></ImageBrush>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="79*"/>
            <RowDefinition Height="79*" />
            <RowDefinition Height="0*" />
            <RowDefinition Height="73*" />
            <RowDefinition Height="91*" />
            <RowDefinition Height="285*" />
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel"
                    Grid.Row="0"
                    Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Foreground="White"
                       Text="{Binding ApplicationTitle}"
                       Style="{StaticResource PhoneTextNormalStyle}" />
            <TextBlock x:Name="PageTitle" Foreground="White"
                       Text="{Binding PageTitle}"
                       Margin="9,-7,0,0"
                       Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <TextBlock Grid.Row="1" Height="41" HorizontalAlignment="Left" Margin="0,26,0,0" Name="lblPlayerName" Text="Player Name" VerticalAlignment="Top" Width="468" Foreground="White" />
        <TextBox Grid.Row="2" Height="70" HorizontalAlignment="Left" Name="txtPlayerName" Text="" VerticalAlignment="Top" Width="480" />
        <TextBlock Grid.Row="4" Height="56" HorizontalAlignment="Left" Margin="0,22,0,0" Name="textBlock1" Text="Player Rating" VerticalAlignment="Top" Width="468" Grid.RowSpan="2" Foreground="White" />
        <TextBox Grid.Row="5" Height="70" HorizontalAlignment="Left" Name="txtRating" InputScope="Number" Text="" VerticalAlignment="Top" Width="480" Background="#FFFBFBFE" />

    </Grid>



便捷



rvenable

推荐答案

您需要重新模板化您的文本框...
IIRC,它具有聚焦"视觉状态,可将其背景设置为当前主题的适当"颜色.您想覆盖该部分.

You need to re-template your TextBox...
IIRC, it has a "Focused" visual state that sets its background to the "appropriate" color for your current theme. You’d want to override that part.

最简单的方法是在Blend中打开项目,右键单击TextBox,然后选择编辑模板".


这篇关于更改我的文本框的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆