通过在Windows Phone8中应用以下样式,PhoneTextBox不会显示提示吗?

KiShOrE
<Style x:Key="chatTextBox" TargetType="toolkit:PhoneTextBox">
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" />
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}" />
        <Setter Property="SelectionBackground" Value="Transparent" />
        <Setter Property="SelectionForeground" Value="Transparent" />
        <Setter Property="Hint" Value="Enter Message" />
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="Template">
        <Setter.Value>
        <ControlTemplate TargetType="toolkit:PhoneTextBox">
        <Grid Background="Transparent">
        <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
        <VisualState x:Name="Normal" />
        <VisualState x:Name="MouseOver" />
        <VisualState x:Name="Disabled">
        <Storyboard>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="EnabledBorder" Storyboard.TargetProperty="Visibility">
        <DiscreteObjectKeyFrame KeyTime="0">
        <DiscreteObjectKeyFrame.Value>
        <Visibility>Collapsed</Visibility>
        </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOrReadonlyBorder" Storyboard.TargetProperty="Visibility">
        <DiscreteObjectKeyFrame KeyTime="0">
        <DiscreteObjectKeyFrame.Value>
        <Visibility>Visible</Visibility>
        </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
        </Storyboard>
        </VisualState>

        </VisualStateGroup>
        <VisualStateGroup x:Name="FocusStates">
        <VisualState x:Name="Focused" />


        <VisualState x:Name="Unfocused" />
        </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Border x:Name="EnabledBorder"
        Margin="{StaticResource PhoneTouchTargetOverhang}"
        Background="{TemplateBinding Background}"
        BorderBrush="{TemplateBinding BorderBrush}"
        BorderThickness="{TemplateBinding BorderThickness}">
        <ContentControl x:Name="ContentElement"
        Margin="{StaticResource PhoneTextBoxInnerMargin}"
        HorizontalContentAlignment="Stretch"
        VerticalContentAlignment="Stretch"
        BorderThickness="0"
        Padding="{TemplateBinding Padding}" />
        </Border>
        <Border x:Name="DisabledOrReadonlyBorder"
        Margin="{StaticResource PhoneTouchTargetOverhang}"
        Background="Transparent"
        BorderBrush="{StaticResource PhoneDisabledBrush}"
        BorderThickness="{TemplateBinding BorderThickness}"
        Visibility="Collapsed">
        <TextBox x:Name="DisabledOrReadonlyContent"
        Background="Transparent"
        FontFamily="{TemplateBinding FontFamily}"
        FontSize="{TemplateBinding FontSize}"
        FontStyle="{TemplateBinding FontStyle}"
        FontWeight="{TemplateBinding FontWeight}"
        Foreground="{StaticResource PhoneDisabledBrush}"
        IsReadOnly="True"
        SelectionBackground="{TemplateBinding SelectionBackground}"
        SelectionForeground="{TemplateBinding SelectionForeground}"
        Text="{TemplateBinding Text}"
        TextAlignment="{TemplateBinding TextAlignment}"
        TextWrapping="{TemplateBinding TextWrapping}" />
        </Border>
        </Grid>
        </ControlTemplate>
        </Setter.Value>
        </Setter>
        </Style>  

我使用上面的代码删除了工具箱中的PhoneTextBox的背景色,一切都很好,但是没有出现提示。应用此样式后。如果有人帮助我,我将不胜感激。

Balasubramani M

根据您的需要,我刚刚为PhoneTextBox创建了样式,并为其应用了此样式。背景在正常和聚焦状态下都是透明的。

<Style x:Key="PhoneTextBoxStyle1" TargetType="toolkit:PhoneTextBox">
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource WhiteBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="SelectionBackground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="SelectionForeground" Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="Hint" Value="sample"/>
        <Setter Property="HintStyle" Value="{StaticResource HintCustomStyle}"/>
        <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="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="HintBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="TextBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="TextBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="TextBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="HorizontalAlignment" Storyboard.TargetName="Text">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <HorizontalAlignment>Stretch</HorizontalAlignment>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="HintBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="HintBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxEditBorderBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </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="{StaticResource PhoneMargin}" 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="{StaticResource PhoneTouchTargetOverhang}">
                            <Grid>
                                <ContentControl x:Name="HintContent" Background="Transparent" Content="{TemplateBinding Hint}" HorizontalAlignment="Left" Margin="3,0,3,0" Style="{TemplateBinding HintStyle}" Visibility="{TemplateBinding ActualHintVisibility}" VerticalAlignment="Center"/>
                                <ContentControl x:Name="ContentElement" BorderThickness="0" HorizontalContentAlignment="Stretch" Margin="{StaticResource PhoneTextBoxInnerMargin}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="Stretch"/>
                            </Grid>
                        </Border>
                        <Border x:Name="TextBorder" BorderBrush="{StaticResource PhoneDisabledBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Margin="{StaticResource PhoneTouchTargetOverhang}" Visibility="Collapsed">
                            <TextBox x:Name="Text" Foreground="{StaticResource PhoneDisabledBrush}" 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="72" VerticalAlignment="Bottom" Width="84">
                            <Image x:Name="ActionIcon" Height="26" Source="{TemplateBinding ActionIcon}" Width="26"/>
                        </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>

最后,将以下代码添加为提示样式。

<Style TargetType="ContentControl" x:Key="HintCustomStyle">
        <Setter Property="FontFamily" Value="Calibri"/>
        <Setter Property="Foreground" Value="Aqua"/>
        <Setter Property="FontSize" Value="30"/>
    </Style>

如果要自定义提示样式,请更改HintCustomStyle。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在Windows Phone 8中设置PhoneTextBox的样式?

来自分类Dev

Windows Phone 8:通过代码在应用中打开Facebook页面

来自分类Dev

Windows Phone 8在TextBox或PhoneTextBox中输入缓慢的文本

来自分类Dev

TextBox可搜索的Longlist选择器在Windows Phone8中显示Outofmemory异常?

来自分类Dev

通过Windows Phone 8上的代码通过多行TextBlock

来自分类Dev

通过C#代码打开Windows Phone 8 Windows日历

来自分类Dev

通过C#代码打开Windows Phone 8 Windows日历

来自分类Dev

如何在Windows Phone 8中通过边框使用按钮

来自分类Dev

如何从Windows Phone8中的弹出窗口导航回去

来自分类Dev

Windows 8中通过OpenVPN的RDP

来自分类Dev

Windows Phone 8:通过代码在应用程序中打开Facebook特定的帖子

来自分类Dev

Windows Phone通过wifi控制电视

来自分类Dev

如何强制Windows Phone 8应用以浅色主题运行

来自分类Dev

如何通过虚拟化运行Windows 8?

来自分类Dev

如何通过虚拟化运行Windows 8?

来自分类Dev

通过Ubuntu修复Windows 8安装

来自分类Dev

在Windows 8上通过JavaScript启动热点

来自分类Dev

在Windows 8上通过Cygwin使用git

来自分类Dev

如何在Windows Phone 8应用中显示帮助

来自分类Dev

如何删除不会通过命令提示符删除的Windows 8恢复分区

来自分类Dev

通过python在Windows中设置代理

来自分类Dev

在Windows中通过WebSocket启用蚊子

来自分类Dev

在Qt中通过Windows GDI绘图

来自分类Dev

通过RegEx在Windows中搜索文件?

来自分类Dev

在Windows中通过npm安装猫鼬

来自分类Dev

无法在 Windows 中通过 pip 安装 wowpalwabbit

来自分类Dev

通过SD卡错误部署Windows Phone应用

来自分类Dev

通过附加Windows Phone应用程序的进程进行调试

来自分类Dev

如何通过Facebook共享Windows Phone应用程序?

Related 相关文章

  1. 1

    如何在Windows Phone 8中设置PhoneTextBox的样式?

  2. 2

    Windows Phone 8:通过代码在应用中打开Facebook页面

  3. 3

    Windows Phone 8在TextBox或PhoneTextBox中输入缓慢的文本

  4. 4

    TextBox可搜索的Longlist选择器在Windows Phone8中显示Outofmemory异常?

  5. 5

    通过Windows Phone 8上的代码通过多行TextBlock

  6. 6

    通过C#代码打开Windows Phone 8 Windows日历

  7. 7

    通过C#代码打开Windows Phone 8 Windows日历

  8. 8

    如何在Windows Phone 8中通过边框使用按钮

  9. 9

    如何从Windows Phone8中的弹出窗口导航回去

  10. 10

    Windows 8中通过OpenVPN的RDP

  11. 11

    Windows Phone 8:通过代码在应用程序中打开Facebook特定的帖子

  12. 12

    Windows Phone通过wifi控制电视

  13. 13

    如何强制Windows Phone 8应用以浅色主题运行

  14. 14

    如何通过虚拟化运行Windows 8?

  15. 15

    如何通过虚拟化运行Windows 8?

  16. 16

    通过Ubuntu修复Windows 8安装

  17. 17

    在Windows 8上通过JavaScript启动热点

  18. 18

    在Windows 8上通过Cygwin使用git

  19. 19

    如何在Windows Phone 8应用中显示帮助

  20. 20

    如何删除不会通过命令提示符删除的Windows 8恢复分区

  21. 21

    通过python在Windows中设置代理

  22. 22

    在Windows中通过WebSocket启用蚊子

  23. 23

    在Qt中通过Windows GDI绘图

  24. 24

    通过RegEx在Windows中搜索文件?

  25. 25

    在Windows中通过npm安装猫鼬

  26. 26

    无法在 Windows 中通过 pip 安装 wowpalwabbit

  27. 27

    通过SD卡错误部署Windows Phone应用

  28. 28

    通过附加Windows Phone应用程序的进程进行调试

  29. 29

    如何通过Facebook共享Windows Phone应用程序?

热门标签

归档