2012-03-28 77 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

謝謝,祝你好運!

相關問題