小编Ala*_*392的帖子

我不希望DatePicker中的消息"SELECT DATE"

我不希望在DatePicker的文本框中显示"选择日期",但我希望看到类似这样的//____或其他文本.

这是我的资源

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="ABC" TargetType="DatePicker">
    <Setter Property="Foreground" Value="#FF333333" />
    <Setter Property="IsTodayHighlighted" Value="True" />
    <Setter Property="SelectedDateFormat" Value="Short" />
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="DisplayDateStart" Value=" 01/01/1990" />
    <Setter Property="DisplayDateEnd" Value="12/31/2090" />        
    <Setter Property="Padding" Value="2"/>
    <Setter Property="FontFamily" Value="Verdana" />
    <Setter Property="FontSize" Value="14" />

    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="HorizontalAlignment" Value ="Center" />
    <Setter Property="VerticalAlignment" Value= "Center" />

    <Setter Property = "Text" Value="{x:Null}" />
    <Setter Property = "SelectedDate" Value="{x:Null}" />

    <Style.Triggers>
        <Trigger Property ="IsMouseOver" …
Run Code Online (Sandbox Code Playgroud)

wpf datepicker

6
推荐指数
3
解决办法
9840
查看次数

从代码背后改变样式

我有这种风格

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="MainMenuStyle" TargetType="{x:Type TextBlock}">

    <Style.Triggers>
        <Trigger Property="IsMouseOver"  Value="True">
            <Setter Property= "Foreground" Value="White"/>
            <Setter Property= "FontSize" Value="22"/>
            <Setter Property= "FontFamily" Value="Arial"/>
        </Trigger>

        <Trigger Property="IsMouseOver"  Value="False">
            <Setter Property= "Foreground" Value="Black" />
            <Setter Property= "FontSize" Value="14"/>
            <Setter Property= "FontFamily" Value="Verdana"/>
        </Trigger>

    </Style.Triggers>

</Style>
Run Code Online (Sandbox Code Playgroud)

现在,如果我想从代码中更改Setter属性值,我该怎么办呢?

在代码背后,我想要这样的东西:

MainMenuStyle.IsMouseOver(True).Foreground = "Red"
MainMenuStyle.IsMouseOver(True).FontSize = 10

MainMenuStyle.IsMouseOver(False).Foreground = "Green"
MainMenuStyle.IsMouseOver(False).FontSize = 100
Run Code Online (Sandbox Code Playgroud)

我必须只使用框架4.

谢谢

wpf xaml

5
推荐指数
1
解决办法
1885
查看次数

颜色样式文本块

我有这个文本块,默认前景色是白色

 <TextBlock Text="First Cmd" Grid.Row="0" TextAlignment="Center"  Margin="4" TextWrapping="Wrap" Foreground="White" Style="{DynamicResource ABC}">
       <TextBlock.InputBindings>
                <MouseBinding  Command="{Binding AAA}" MouseAction="LeftClick" />
       </TextBlock.InputBindings>
 </TextBlock>
Run Code Online (Sandbox Code Playgroud)

当鼠标位于文本块上时,forground颜色必须以黑色更改,但此样式不起作用.为什么?

<Style x:Key="ABC" TargetType="{x:Type TextBlock}">
    <Style.Triggers>
        <Trigger Property ="IsMouseOver" Value="True">
            <Setter Property= "Foreground" Value="Black">
        </Trigger>
    </Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)

wpf xaml

3
推荐指数
1
解决办法
1586
查看次数

标签 统计

wpf ×3

xaml ×2

datepicker ×1