Topic Author
Posts: 95
Joined: 23 Oct 2014, 19:54

Can an attached property be defined in a different assembly than the one it is used in?

22 Aug 2019, 22:43

I have the following attached property which works fine if it's defined locally...
    public static class FocusExtension
        public static bool GetIsFocused(DependencyObject obj)
            return (bool)obj.GetValue(IsFocusedProperty);

        public static void SetIsFocused(DependencyObject obj, bool value)
            obj.SetValue(IsFocusedProperty, value);

        public static readonly DependencyProperty IsFocusedProperty =
                "IsFocused", typeof(bool), typeof(FocusExtension),
                new UIPropertyMetadata(false, OnIsFocusedPropertyChanged));

        private static void OnIsFocusedPropertyChanged(
            DependencyObject d,
            DependencyPropertyChangedEventArgs e)
            var uie = (UIElement)d;
            if ((bool)e.NewValue)
                uie.Focus(); // Don't care about false values.

But then when I move it to an assembly "NoesisHelpers" and try to use it in my XAML by referencing that assembly, it doesn't work:
             <Grid Name="tvRootGrid" nh:FocusExtension.IsFocused="{Binding Path=IsFocused}">

Is that expected?

User avatar
Site Admin
Posts: 2062
Joined: 22 Dec 2011, 19:20

Re: Can an attached property be defined in a different assembly than the one it is used in?

23 Aug 2019, 01:10

This is something that has been reported several times in the past (#1016).

The problem is that Noesis is not loading assemblies even if they are specified in the xaml, so for now you should load them in the domain manually before parsing a xaml that uses those assemblies.

We will provide a solution for this in a future release (initially planned for version 2.2.5).

Who is online

Users browsing this forum: No registered users and 1 guest