Page 1 of 1

[RESOLVED] AttachedProperties [Unity]

Posted: 05 Dec 2013, 09:00
by ai_enabled
I'm looking for a way to define attached property in NoesisGUI 1.1.2 Unity3D. In WPF is code like this:
public class TestClass: DependencyObject
{
		public static readonly DependencyProperty PropNameProperty = 
			DependencyProperty.RegisterAttached(
				"PropName", 
				typeof(object), 
				typeof(TestClass), 
				new FrameworkPropertyMetadata(null, PropertyChangedCallback));

		private static void PropertyChangedCallback(
				DependencyObject dependencyObject, 
				DependencyPropertyChangedEventArgs args)
		{
			FrameworkElement fe = dependencyObject as FrameworkElement;
			if (fe == null) return;
                        // property was assigned/removed from FrameworkElement
			// so we can do something useful here
		}

	        public static object GetPropName(UIElement element)
		{
			return element.GetValue(PropNameProperty);
		}

		public static void SetPropName(UIElement element, object value)
		{
			element.SetValue(PropNameProperty, value);
		}
}
I've tried to register attached property in NoesisGUI as DependencyProperty (as described in docs), and it seems to work except I can't find the way to add callback handler to handle event when this property was attached to FrameworkElement. Is there any way to achieve it in the NoesisGUI?

Re: AttachedProperties [Unity]

Posted: 05 Dec 2013, 17:27
by sfernandez
Hi,

The PropertyChangedCallback cannot be specified in Unity yet. We have an open ticket regarding this issue and will be solved in a future version.

Sorry for the inconvenience.

Re: AttachedProperties [Unity]

Posted: 05 Dec 2013, 17:36
by ai_enabled
We have an open ticket regarding this issue and will be solved in a future version.
Nice to hear. It's very important for our project - we're trying to implement custom tooltips system (and we're already complete it in WPF), but without this feature it's not possible.