更改我的文本框的背景颜色

编程入门 行业动态 更新时间:2024-10-27 13:28:35
本文介绍了更改我的文本框的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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,它具有聚焦"视觉状态,可将其背景设置为当前主题的适当"颜色.您想覆盖该部分.

Youneed 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,然后选择编辑模板".

更多推荐

更改我的文本框的背景颜色

本文发布于:2023-06-09 04:09:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/594940.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本框   颜色   背景

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!