同意ls用Storyboard在Expression Blend,画一矩型,按F7,进入Animation Workspace.
增加一个Event,增加一个Action, 在时间线开始处增加一个关键帧,在时间线适当地方按住Shift键放大矩型。OK,that's all.有点像Flash里做动画似的。没有闪烁~

解决方案 »

  1.   

    我用了Animation也闪,我在试试Storyboard吧
      

  2.   

    我在线程里调用form的invoke,是form的线程修改位置的,canvas是form的子窗口
      

  3.   

    参考:在WPF的用户线程中更新UI界面 
     
    WPF中UI线程队列由Dispatcher来管理和调度,所以当用户线程中更新UI时,必须通过Dispatche来调度,下面这个小例子将给用户展示如何在用户线程中更新当前的时间.
     
    前台的XAML代码如下:
    <Windowx:Class="ThreadInvoke.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ThreadInvoke"Height="300"Width="300"
        >
     <StackPanelOrientation="Vertical">
        <StackPanelOrientation="Horizontal">
          <ButtonContent="Ok"Click="okClick"Width="50"/>
          <ButtonContent="Stop"Click="stopClick"Width="50"/>
        </StackPanel>
        <TextBoxName="timeText"></TextBox>
     </StackPanel>
    </Window>
     
    后台的主要代码如下:
     
    //申明一个代理用于想UI更新时间
    private delegate void DelegateSetCurrentTime();
     
    //申明一个变量,用于停止时间的跳动
    private bool stopFlag = false;
     
    //处理开始和结束事件
    private void okClick(object sender,RoutedEventArgs args)
    {
                stopFlag = false;
                Thread thread = new Thread(new ThreadStart(refreshTime));
                thread.Start();
    }
     
    private void stopClick(object sender, RoutedEventArgs args)
    {
                stopFlag = true;
    }
     
    //用户线程的实现函数
    private void refreshTime()
    {
                while (!stopFlag)
                {
    //向UI界面更新时钟显示                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.SystemIdle, new DelegateSetCurrentTime(setCurrentTime));
                }
    }
     
    private void setCurrentTime()
    {
                String currentTime = System.DateTime.Now.ToString();
                timeText.Text = currentTime;
    }
      

  4.   

    前几天刚了解了一下WPF,XAML,还可把环境搭上了
      

  5.   

    非常感谢namhyuk提供的跨线程修改UI的方法,但是闪烁的问题仍然存在
      

  6.   

    public  BackgroundWorker bw = null;
    public mainwindow()
    {
        this.InitializeComponent();
        bw = new BackgroundWorker();
        bw.DoWork += new DoWorkEventHandler( bw_DoWork );//把自己的代码放bw_DoWork函数里ok
    }
    private void bw_DoWork( object sender, DoWorkEventArgs e )
    {
        Dispatcher.BeginInvoke(DispatcherPriority.Loaded,    //这就是单独执行的,当然段这段可以放在别的函数里
                 new Action(delegate()
                 {             }
    }