0
<Hyperlink Command="{Binding Path=Source1}">
    <TextBlock x:Name="DescriptionText" TextWrapping="Wrap">
        <TextBlock.Style>
            <Style>
                <Setter Property="TextBlock.Text" Value="Click here to set Source1"/>               
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=IsActive}" Value="False">
                        <Setter Property="TextBlock.Text" Value="{Binding Path=Source1Des, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TextBlock.Style>
    </TextBlock>
</Hyperlink>

我只想下划线修剪文本。怎么做?

4

1 回答 1

1

使用 Run 代替 Textblock

    <TextBlock TextWrapping="Wrap">
        <Hyperlink Command="{Binding Path=Source1}">
            <Run>
                <Run.Style>
                    <Style TargetType="Run">
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Text"  Value="My mouse is over" />
                            </Trigger> 
                        </Style.Triggers>
                        <Setter Property="Text"  Value="Click here to set Source1" />
                    </Style>
                </Run.Style>
            </Run>
        </Hyperlink>
    </TextBlock>

另请参阅此 stackoverflow 线程

于 2012-10-10T10:51:54.070 回答