Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Animating parts of a custom FrameworkElement (OnRender and DoubleAnimation question)

 
 
Old 06-18-2006   #1 (permalink)
Illumineo


 
 

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 SpecsSystem Spec
Old 06-20-2006   #2 (permalink)
viliescu


 
 

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 SpecsSystem Spec
Old 06-26-2006   #3 (permalink)
Illumineo


 
 

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 SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Custom theme question General Discussion
Directory Custom or Modification Question Vista General
Custom Picture Question Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46