我有一个屏幕包含大约15-20个TextBlocks,每个TextBlocks绑定到一个不同的属性,起初所有TextBlocks都是空的文本更新来自其他客户端.
我想要做的是在文本更改时为闪烁文本设置动画3秒.
我使用下面的故事板来实现这一点:
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<EventTrigger RoutedEvent="UIElement.MouseEnter">
<BeginStoryboard >
<Storyboard Duration="0:0:03">
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.5" Value="{x:Static Visibility.Hidden}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:01" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:01.5" Value="{x:Static Visibility.Hidden}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:02" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:02.5" Value="{x:Static Visibility.Hidden}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:03" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)
使用鼠标输入事件文本闪存很好但使用Binding.TargetUpdated事件没有触发任何事情.
有人知道TextBlock文本更改时引发的事件吗?
我有一个自定义的wpf控件.它基本上是一个文本块,能够对文本应用填充和描边.它已经被一个类继承了.问题是它没有像fontfamily这样的文本块属性.我想用textblock继承这个控件,所以它可以使用它的所有属性.自定义控制代码如下
namespace CustomXaml
{
public class OutlinedText : FrameworkElement, IAddChild
{
#region Private Fields
private Geometry _textGeometry;
#endregion
#region Private Methods
/// <summary>
/// Invoked when a dependency property has changed. Generate a new FormattedText object to display.
/// </summary>
/// <param name="d">OutlineText object whose property was updated.</param>
/// <param name="e">Event arguments for the dependency property.</param>
private static void OnOutlineTextInvalidated(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((OutlinedText)d).CreateText();
}
#endregion
#region FrameworkElement Overrides
/// <summary>
/// OnRender override draws the geometry of the …Run Code Online (Sandbox Code Playgroud) 我需要文本块,它可以在全文和修剪文本之间切换,如下图所示:

并且找不到类似的东西。
Expander 与此类似,但默认情况下它会显示修剪后的完整版本(标题中修剪,内容完整)。
我想写一些带有附加属性的东西,但我需要绘制按钮,检查它是否需要按钮(文本没有被修剪),执行折叠和展开逻辑 - 简而言之,我感觉像在这里发明轮子,有人应该以前做过这个,只是我可能找不到它?