private void FlyOutSettingView(object o) { ColumnDefinition SettingCol = _mainWindow.SettingCol; ColumnDefinition InfoCol = _mainWindow.InfoCol; ColumnDefinition ModelViewCol = _mainWindow.ModelViewCol; ModelViewCol.Width = new GridLength(ModelViewCol.ActualWidth, GridUnitType.Pixel); GridLengthAnimation gla = new GridLengthAnimation { From = new GridLength(SettingCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(0, GridUnitType.Star), Duration = new TimeSpan(0, 0, 0, 0, 150), FillBehavior = FillBehavior.HoldEnd }; //myanim.Completed += (s, e) => //{ // //your completed action here //}; GridLengthAnimation gla2 = new GridLengthAnimation { From = new GridLength(InfoCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(SettingCol.ActualWidth, GridUnitType.Pixel), Duration = new TimeSpan(0, 0, 0, 0, 150), FillBehavior = FillBehavior.HoldEnd }; SettingCol.BeginAnimation(ColumnDefinition.WidthProperty, gla); InfoCol.BeginAnimation(ColumnDefinition.WidthProperty, gla2); }
private void FlyInSettingView(object o) { ColumnDefinition SettingCol = _mainWindow.SettingCol; ColumnDefinition InfoCol = _mainWindow.InfoCol; ColumnDefinition ModelViewCol = _mainWindow.ModelViewCol; var storyboard = new Storyboard(); //先把ModelViewCol設定成固定值 ModelViewCol.Width = new GridLength(ModelViewCol.ActualWidth, GridUnitType.Pixel); //設定InfoCol從當前Pixel長度到0Pixel GridLengthAnimation gla2 = new GridLengthAnimation { From = new GridLength(InfoCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(0, GridUnitType.Pixel), Duration = new TimeSpan(0, 0, 0, 0, 150), FillBehavior = FillBehavior.HoldEnd }; Storyboard.SetTargetProperty(gla2, new PropertyPath(ColumnDefinition.WidthProperty)); Storyboard.SetTarget(gla2, InfoCol); //設定SettingCol從當前Pixel長度到InfoCol動畫前的Pixel長度 GridLengthAnimation gla = new GridLengthAnimation { From = new GridLength(SettingCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(InfoCol.ActualWidth, GridUnitType.Pixel), Duration = new TimeSpan(0, 0, 0, 0, 200), FillBehavior = FillBehavior.HoldEnd, }; Storyboard.SetTargetProperty(gla, new PropertyPath(ColumnDefinition.WidthProperty)); Storyboard.SetTarget(gla, SettingCol); storyboard.Children.Add(gla); storyboard.Children.Add(gla2); _mainWindow.BeginStoryboard(storyboard); }
/// <summary> /// 將觀看Model的View放到最大,tracking的時候用 /// </summary> private void AmplifyModelView() { GridLengthAnimation gla = new GridLengthAnimation { From = new GridLength(_mainWindow.SettingCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(0, GridUnitType.Star), Duration = new TimeSpan(0, 0, 0, 0, 150), FillBehavior = FillBehavior.HoldEnd }; GridLengthAnimation gla2 = new GridLengthAnimation { From = new GridLength(_mainWindow.InfoCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(1, GridUnitType.Star), Duration = new TimeSpan(0, 0, 0, 0, 150), FillBehavior = FillBehavior.HoldEnd }; GridLengthAnimation gla3 = new GridLengthAnimation { From = new GridLength(_mainWindow.ModelViewCol.ActualWidth, GridUnitType.Pixel), //To = new GridLength(_mainWindow.MainGrid.ActualWidth, GridUnitType.Pixel), To = new GridLength(5, GridUnitType.Star), Duration = new TimeSpan(0, 0, 0, 0, 200), FillBehavior = FillBehavior.Stop, }; gla3.Completed += (s, e) => { _mainWindow.ModelViewCol.Width = new GridLength(_mainWindow.MainGrid.ActualWidth, GridUnitType.Pixel); }; _mainWindow.SettingCol.BeginAnimation(ColumnDefinition.WidthProperty, gla); _mainWindow.InfoCol.BeginAnimation(ColumnDefinition.WidthProperty, gla2); _mainWindow.ModelViewCol.BeginAnimation(ColumnDefinition.WidthProperty, gla3); }
/// <summary> /// 將Grid回復到原始狀態 /// </summary> private void RestoreGridLength() { GridLengthAnimation gla = new GridLengthAnimation { From = new GridLength(_mainWindow.SettingCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(0, GridUnitType.Pixel), Duration = new TimeSpan(0, 0, 0, 0, 150), FillBehavior = FillBehavior.HoldEnd }; GridLengthAnimation gla2 = new GridLengthAnimation { From = new GridLength(_mainWindow.InfoCol.ActualWidth, GridUnitType.Pixel), To = new GridLength(_mainWindow.SettingCol.ActualWidth, GridUnitType.Pixel), Duration = new TimeSpan(0, 0, 0, 0, 150), FillBehavior = FillBehavior.HoldEnd }; _mainWindow.SettingCol.BeginAnimation(ColumnDefinition.WidthProperty, gla); _mainWindow.InfoCol.BeginAnimation(ColumnDefinition.WidthProperty, gla2); }