![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Animating parts of a custom FrameworkElement (OnRender and DoubleAnimation question) My diagramming application uses custom controls and is somewhat similar (in appearance, at least) to the class-designer in VS2005. The overriden OnRender works well but now I want to animate the collapse/expand behavior of the 'class shape'. I was able to implement it in XAML but porting it to code is somewhat difficult. In particular, the public expand method: public void Expand() { expanded = true; this.InvalidateVisual(); DoubleAnimation anim = new DoubleAnimation(0.0, 1.0, new Duration(new TimeSpan(0, 0, 4))); xrg.BeginAnimation(FrameworkElement.OpacityProperty, anim); //xrg is a sub-element of the control } does not produce a visual effect. Obviously the OnRender is not called when the sub-element is animated. How should I do this? In general, how to animate part of a custom control? [Thx] |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Animating parts of a custom FrameworkElement (OnRender and DoubleA From what I know if you use visual layer programming you will sacrifice some benefits of the high level stuff - like animations, databinding etc.. Just out of curiosity, why did you go with visuals? -- Valentin Iliescu [MVP - Client Application Development] "Illumineo" wrote: > My diagramming application uses custom controls and is somewhat similar > (in appearance, at least) to the class-designer in VS2005. The > overriden OnRender works well but now I want to animate the > collapse/expand behavior of the 'class shape'. I was able to implement > it in XAML but porting it to code is somewhat difficult. In particular, > the public expand method: > > public void Expand() > { > expanded = true; > this.InvalidateVisual(); > DoubleAnimation anim = new DoubleAnimation(0.0, 1.0, new > Duration(new TimeSpan(0, 0, 4))); > xrg.BeginAnimation(FrameworkElement.OpacityProperty, anim); > //xrg is a sub-element of the control > } > > does not produce a visual effect. Obviously the OnRender is not called > when the sub-element is animated. How should I do this? In general, how > to animate part of a custom control? > > [Thx] > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Animating parts of a custom FrameworkElement (OnRender and DoubleA It seems I should use the CompositionTarget class, as the documentation says, to '...create custom drawings or animations based on a per-frame callback..' I was able to achieve what I wanted to do by replacing the custom control by a UserControl which allowed me to have the animation in XAML rather than in code. In any case, what I have learned is this: you cannot trust the rendering engine to do something for you. The intrinsic refresh-algorithm is untouchable even if you call InvalidateVisual or InvalidateArrange. Maybe I'm so used to the painting loop in Win32 or Net2. The drawback of this is that it's very difficult to know what you have to do to optimize the code in function of 'big' diagrams or graph/diagrammatic processes. |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Custom theme question | General Discussion | |||
| Directory Custom or Modification Question | Vista General | |||
| Custom Picture Question | Vista account administration | |||