Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 在windows phone中定义PhoneTextBox的样式_Windows Phone 7_Textbox_Styles - Fatal编程技术网

Windows phone 7 在windows phone中定义PhoneTextBox的样式

Windows phone 7 在windows phone中定义PhoneTextBox的样式,windows-phone-7,textbox,styles,Windows Phone 7,Textbox,Styles,我正在重写PhoneTextBox的样式,将默认背景更改为“transpanrent”,将前景更改为“白色”,将边框笔刷更改为“白色”,因为我想设计一个黑色主题 但是出现了一个问题,文本输入指示器消失了。我感谢的原因是文本输入指示器的前景是黑色的,所以用户看不到它。但是我找不到一种方法来定义文本输入指示器的前景。任何提示都将被告知 另外,我不知道如何描述该指示器,因此我编造了“文本输入指示器”一词,如下所示: 正常情况下,黑色垂直线出现 重写样式后,用户看不到黑色垂直线: 以及xaml代码:

我正在重写PhoneTextBox的样式,将默认背景更改为“transpanrent”,将前景更改为“白色”,将边框笔刷更改为“白色”,因为我想设计一个黑色主题

但是出现了一个问题,文本输入指示器消失了。我感谢的原因是文本输入指示器的前景是黑色的,所以用户看不到它。但是我找不到一种方法来定义文本输入指示器的前景。任何提示都将被告知

另外,我不知道如何描述该指示器,因此我编造了“文本输入指示器”一词,如下所示:

正常情况下,黑色垂直线出现

重写样式后,用户看不到黑色垂直线:

以及xaml代码:

 <Style x:Key="PhoneTextBoxStyle" TargetType="toolkit:PhoneTextBox">
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="BorderBrush" Value="White"/>
        <Setter Property="SelectionBackground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="SelectionForeground" Value="White"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Padding" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:PhoneTextBox">
                    <Grid x:Name="RootGrid" Background="Transparent">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Disabled">
                                </VisualState>
                                <VisualState x:Name="Enabled">
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="LengthIndicatorStates">
                                <VisualState x:Name="LengthIndicatorVisible">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="RootGrid">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0, 0, 0, 27"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0.6"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0:0:0.350" To="32" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="LengthIndicator">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="6"/>
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="LengthIndicatorHidden">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0:0:0.350" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="LengthIndicator">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="6"/>
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="RootGrid">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0, 0, 0, 0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.350" Value="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.350">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="LengthIndicatorBorder">
                            <TextBlock x:Name="LengthIndicator" Foreground="{StaticResource PhoneContrastBackgroundBrush}" FontSize="{StaticResource PhoneFontSizeNormal}" HorizontalAlignment="Right" Margin="0" Opacity="0" TextAlignment="Right" VerticalAlignment="Bottom">
                                    <TextBlock.RenderTransform>
                                        <TranslateTransform/>
                                    </TextBlock.RenderTransform>
                            </TextBlock>
                        </Border>
                        <Border x:Name="HintBorder" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" Margin="0">
                            <Grid>
                                <ContentControl x:Name="HintContent" Background="Transparent" Content="{TemplateBinding Hint}"
                                                HorizontalAlignment="Left" Margin="3,5,3,0" Style="{TemplateBinding HintStyle}" 
                                                Foreground="Gray"
                                                Visibility="{TemplateBinding ActualHintVisibility}" VerticalAlignment="Top"/>
                                <ContentControl x:Name="ContentElement" BorderThickness="0" HorizontalContentAlignment="Stretch" 
                                                Margin="{StaticResource PhoneTextBoxInnerMargin}" 
                                                Padding="{TemplateBinding Padding}"
                                                VerticalContentAlignment="Stretch"/>
                            </Grid>
                        </Border>
                        <Border x:Name="TextBorder" BorderBrush="White" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="Transparent" Margin="0" Visibility="Collapsed">
                            <TextBox x:Name="Text" Foreground="White" 
                                     FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" 
                                     FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}"
                                     HorizontalAlignment="Left" SelectionForeground="{TemplateBinding SelectionForeground}" 
                                     SelectionBackground="{TemplateBinding SelectionBackground}" 
                                     TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="{TemplateBinding TextWrapping}" 
                                     Text="{TemplateBinding Text}"/>
                        </Border>
                        <Border x:Name="ActionIconBorder" Background="Transparent" HorizontalAlignment="Right" Height="54" VerticalAlignment="Bottom" Width="54">
                            <Image x:Name="ActionIcon" Height="54" Source="{TemplateBinding ActionIcon}" Width="54"/>
                        </Border>
                        <TextBlock x:Name="MeasurementTextBlock" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" IsHitTestVisible="False" Margin="8" Opacity="0" TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="{TemplateBinding TextWrapping}" Text="{TemplateBinding Text}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

看得见的
崩溃

您可能正在寻找
CaretBrush
SelectionBackground
SelectionForeground
。我不知道这些属性是否在
toolkit:PhoneTextBox
中绑定,但您肯定可以在任何情况下手动重新设置它的样式。

可能您正在寻找
CaretBrush
SelectionBackground
SelectionForeground
。我不知道这些属性是否在
toolkit:PhoneTextBox
中绑定,但在任何情况下都可以手动重新设置其样式。

如果有人正在寻找更改长度指示器属性的解决方案

<Border x:Name="LengthIndicatorBorder">
    <TextBlock x:Name="LengthIndicator" HorizontalAlignment="Right" Margin="0" Opacity="0" TextAlignment="Right" VerticalAlignment="Bottom">
            <TextBlock.RenderTransform>
                <TranslateTransform/>
            </TextBlock.RenderTransform>
    </TextBlock>
</Border>


如果有人正在寻找更改长度指示器属性的解决方案,则需要此块

<Border x:Name="LengthIndicatorBorder">
    <TextBlock x:Name="LengthIndicator" HorizontalAlignment="Right" Margin="0" Opacity="0" TextAlignment="Right" VerticalAlignment="Bottom">
            <TextBlock.RenderTransform>
                <TranslateTransform/>
            </TextBlock.RenderTransform>
    </TextBlock>
</Border>


这个街区正是你需要的

很好,谢谢你,@Ku6opr。我只需要重新设计caretBrush。很高兴能帮上忙。在文本选择过程中检查颜色,以便在黑色和白色主题中都能发挥作用,alsoNice,谢谢,@Ku6opr。我只需要重新设计caretBrush。很高兴能帮上忙。在文本选择过程中检查颜色,以便在深色和白色主题中都能发挥作用