disable/enable behavior by code

Aug 10, 2011 at 7:46 PM

hy,

My need is to disable objects behaviors in specific moment and after reanable. I try to use IsScaleEnabled, IsRotateEnable.. IsTranslateXEnable and IsTraslateYEnable setting them all to false.

But I encountered a problem when setting IsScaleEnable to false because istantaneally the image disappear from the screen.  I try also to detach all behaviors but the object resizes back to the original position.

May somebody help me?

thanks a lot in advance! and as Davide sayd Happy Silverlighting!

Luca

Aug 10, 2011 at 8:05 PM
Edited Aug 10, 2011 at 8:16 PM

Hi Luca,

thanks for the feedback and the mention ;)

I'll try to reproduce the issue and come back to you asap.

Eventually, can you attach a sample project reproducing the problem?

Thanks,

Davide

Aug 11, 2011 at 1:12 PM

Hi Davide, here an example of code:

bye

            /// <summary>
            /// Enable/Disable all the beaviors
            /// </summary>
            private bool _BehaviorsLocked;
            public bool BehaviorsLocked {
                get
                {
                    return _BehaviorsLocked;
                }
                set
                {
                    _BehaviorsLocked = value;

                    if (!value)
                    {
                        IsScaleEnabled = true;
                        IsTranslateYEnabled = true;
                        IsTranslateXEnabled = true;
                        //IsRotateEnabled = true;  // <--  this doesn't work!                              }
                    else {
                        IsScaleEnabled = false;
                        IsTranslateYEnabled = false;
                        IsTranslateXEnabled = false;
                        //IsRotateEnabled = false; //  <--  this doesn't work!                    
                    }


                }
           
         
            }

Aug 11, 2011 at 1:41 PM

Hi Davide, onother question... I'd like to resize a movie to fit LayoutRoot. How can I do?

many thanks!

Aug 11, 2011 at 8:11 PM

Hi Luca,

I've posted a fix for rotation in the Change Set 81879, let me know if it works for you.

About the resize: do you want to resize to fit LayoutRoot when a gesture occurs (like doubletap)?

Thanks,

Davide

Aug 11, 2011 at 8:56 PM

thank you for your fix, I'll try asap, regardling the resize, I need to enlarge the object to full size when user touch a 'zoom' button.

I trying to do this with a Silverlight animation, so I need to know when the object is and whare object will be, in position, size, and rotation.

I also seen that after a simple animation of any object, If you try to manipulate  it, the object position start from the original position before its silverlight animation, so I think is necessary at the end of animation, to inform MultitouchManipulationBehavior class about new positon parameters of the object  . 

are you agree?

thanks

bye

Aug 11, 2011 at 11:12 PM

Hi Luca,

I'm updating the behavior adding new properties: CenterX, CenterY, Scale, Rotation exposing the corresponding values in order to enable different manipulations.

These will be dependecy properties so you'll be able to use them with data binding, animations and so on.

Thanks,

Davide

Aug 12, 2011 at 3:46 PM

Hi Davide,

great! now enabling and disabling behavior functions work perfectly! 

Hovever I notice that   IsTranslateXEnabled and  IsTranslateYEnabled don't work distinctly, I meen if you lock horizontal movement with setting IsTranslateXEnabled = false, also vertical movement is locked, and vice versa.

bye

Luca

Aug 12, 2011 at 6:18 PM

Hi Luca,

glad it worked, many thanks for the feedback!

Yes, TranslateX and TranslateY don't work distinctly for now, probably they'll be replaced by a single property for the moment.

Cheers,

Davide

Aug 13, 2011 at 8:06 AM

Hi Davide,

I've tested CenterX, CenterY, Scale, Rotation and they works fine but Scale and Rotation. I replace their property code in Multitouch.Behaviors.Silverlight4.MultitouchBehavior with same code of CenterX and now they work fine.

thankyou and have a good day or evening.. depend of whare you are in the world .. :)

Luca

Aug 13, 2011 at 11:29 AM

Thanks Luca,

I've updated the code for Scale and Rotation, let me know if it works now.

Davide