How to set magnetic controlls in code

Oct 3, 2012 at 9:53 AM

I know that in xaml it is possible to set the magnetic controls by adding

local:MagneticPropertyHolder.IsMagnetic="True"
but, is it also possible to do it in the code? How?

Oct 3, 2012 at 1:30 PM
Edited Oct 3, 2012 at 1:31 PM

As can be find also in this post:

This looks like an attached property.

To set it, you'd do something like

tb.SetValue(MagneticPropertyHolder.IsMagneticProperty, true);

or possibly

MagneticPropertyHolder.SetIsMagnetic(tb, true);

A quick glance at the Kinect Toolbox source code suggests that either would work. The second is more type safe.

See How to I access an attached property in code behind? for more information.