2012-03-28 24 views
3

我使用以下代码来注入视图成网格:使用户控件从屏幕的一侧“滑出”?

private void OnShowNotesRequested(UserControl view) 
     { 
      if (view == null) throw new NotSupportedException("View should not be null"); 

      // Skip first GridRow - this is usually Toolbar 
      if (this.AssociatedObject.RowDefinitions.Count > 1) 
      { 
       view.SetValue(Grid.RowSpanProperty, this.AssociatedObject.RowDefinitions.Count - 1); 
       view.SetValue(Grid.RowProperty, 1); 
      } 

      view.SetValue(Grid.ColumnSpanProperty, this.AssociatedObject.ColumnDefinitions.Count == 0 ? 1 : this.AssociatedObject.ColumnDefinitions.Count); 
      view.Width = 500; 
      view.HorizontalAlignment = HorizontalAlignment.Right; 

      this.AssociatedObject.Children.Add(view); 
     } 

基本上,我添加视图作为子到电网。它靠码头到右边。

我想让它看起来像这个视图滑出右侧并停下来。我不知道如何接近它,我该怎么做才能达到这种视觉效果。任何指针什么和我需要添加的地方?也许链接到类似的效果?

我发现了一些动画代码在这里:http://forums.silverlight.net/t/82441.aspx

这是有道理的,但是当我躲在我的看法 - 我完全可视树,像这样将其删除:this.AssociatedObject.Children.Remove(view)不知道如何“等待”,然后将其删除。

+1

我推荐Expression Blend。 – Jordan 2012-03-28 14:31:14

回答

1

看看Microsofts Expression Blend工具,它是专门为创建这些类型的视觉效果而创建的。

你想要做的事情可以用故事板来完成,而且很简单!基本上,一旦故事板创建完毕(根据时间(或帧)定义开始位置和结束位置的情况),您可以触发故事板在特定事件触发时播放。

但是我这里知道这是不是一个确切的答案被一些教程,让你感动:

http://www.silverlightbuzz.com/2009/10/12/animating-with-storyboards-in-blend/ http://www.c-sharpcorner.com/uploadfile/mamta_m/creating-and-using- storyboards-in-blendsilverlight-part-i/ http://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&ved=0CE4QFjAD&url=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fcc295092.aspx&ei=NDRzT42uPNS_8gPrz6xW&usg=AFQjCNGwT_hEkwGBXzS3holaM1g85I0S5Q&sig2=dSDJ6lL0CR3-nIR7WQ739g

谢谢,祝你好运!

相关问题