【发布时间】:2014-08-02 18:07:29
【问题描述】:
正如您在下面看到的,我有一个 Canvas 允许您在单个 Thumb 控件周围拖动。将 ProgressBars IsIndeterminate 值设置为 false 时,拇指在您拖动它时会非常灵敏,但一旦您将其设置为 true,即使对于这种简单的情况,拇指也会落后大量帧。当您添加更多控件时,它会变得非常明显。
设置 Timeline.DesiredFrameRateProperty 似乎没有任何区别。
我能做些什么来避免这个问题吗?
<Window x:Class="WpfApplication30.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas>
<Thumb Width="50"
Height="50"
Canvas.Left="10"
Canvas.Top="10"
DragDelta="Thumb_DragDelta"/>
<ProgressBar Width="200"
Height="20"
IsIndeterminate="True" />
</Canvas>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 1 });
}
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
UIElement obj = sender as UIElement;
Canvas.SetLeft(obj, Canvas.GetLeft(obj) + e.HorizontalChange);
Canvas.SetTop(obj, Canvas.GetTop(obj) + e.VerticalChange);
}
}
【问题讨论】:
-
不在我的机器上。甚至没有 5 个酒吧。
-
您使用的是什么版本的 .Net?
-
您是否使用自定义 wpf 主题或任何 progresbar 样式?
标签: c# wpf performance animation