Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

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

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 06-18-2006   #1 (permalink)
Illumineo
Guest


 

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
Guest


 

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
Guest


 

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
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question from .net beginner regarding rebuilding custom class library jz3 .NET General 3 03-13-2008 02:36 PM
Custom Picture Question Mike McCollister Vista account administration 0 06-11-2007 07:40 PM
API Standards question: FrameworkElement.Focusable Keith Patrick Avalon 3 02-27-2006 02:11 AM
DoubleAnimation.Completed and DoubleAnimation.CurrentStateInvalidated Lei Jiang Avalon 0 02-26-2006 06:05 AM
How to get the coordinates of a FrameworkElement? Jason Dolinger Avalon 2 01-31-2006 07:00 AM


Vistax64.com 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 2005-2008

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 47 48 49 50 51