我找不到像IsScrolling
东西,所以我将接近这样的:
<Popup Name="docPopup" AllowsTransparency="True" PlacementTarget="{x:Reference docViewer}" Placement="Center">
<Border Background="Black" CornerRadius="5" Padding="10" BorderBrush="White" BorderThickness="1">
<TextBlock Foreground="White">
<Run Text="{Binding ElementName=docViewer, Path=MasterPageNumber, Mode=OneWay}"/>
<Run Text="/"/>
<Run Text="{Binding ElementName=docViewer, Path=PageCount, Mode=OneWay}"/>
</TextBlock>
</Border>
</Popup>
<DocumentViewer Name="docViewer" ScrollViewer.ScrollChanged="docViewer_ScrollChanged"/>
的文档滚动时,应会显示弹出,那么它应该褪色过了一段时间。这是在处理程序中完成:
DoubleAnimationUsingKeyFrames anim;
private void docViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (anim == null)
{
anim = new DoubleAnimationUsingKeyFrames();
anim.Duration = (Duration)TimeSpan.FromSeconds(1);
anim.KeyFrames.Add(new DiscreteDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0))));
anim.KeyFrames.Add(new DiscreteDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5))));
anim.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))));
}
anim.Completed -= anim_Completed;
docPopup.Child.BeginAnimation(UIElement.OpacityProperty, null);
docPopup.Child.Opacity = 1;
docPopup.IsOpen = true;
anim.Completed += anim_Completed;
docPopup.Child.BeginAnimation(UIElement.OpacityProperty, anim);
}
void anim_Completed(object sender, EventArgs e)
{
docPopup.IsOpen = false;
}
编辑:事件触发时也通过鼠标滚轮等进行滚动,你可以在处理程序中if (Mouse.LeftButton == MouseButtonState.Pressed)
包裹的一切,不是100%准确,但谁与滚动MouseWheel而左键单击?
这对我来说是新鲜事物,从来没有玩过PopUp那么多..会试试这个肯定.. – 2011-04-23 09:11:35
这工作得很好,我有一个查询,虽然我张贴在这里 - http://stackoverflow.com/questions/5831514/tooltip-on-scrollviewer-in-documentviewer-in-case-of-deferred-scrolling仅与此相关。你能帮我解决这个问题吗? – 2011-04-29 17:57:07