title: WPF - Attached property needs to reference another bound attached property
body: <p>I have created an attached property to set the visibility of a UIElement based on a particular enum value. This works fine. However, I need to extend this so that the visibility can be overriden based on the "status" of the sender.</p>
  
  <p>How can I achieve this? I had thought that I could create another attached property which the first attached property could reference, however I need to be able to bind a value to the second attached property rather than just set to an enum value.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Below is an example of my problem:</p>
  
  <pre><code>&lt;Window x:Class="AttachedProperty.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:attachedProperty="clr-namespace:AttachedProperty"
      Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Grid&gt;
      &lt;StackPanel&gt;
          &lt;TextBlock Text="Button should be enabled?"/&gt;
          &lt;CheckBox IsChecked="{Binding Path=CanClick}"/&gt;
          &lt;Button Content="Click Me" IsEnabled="{Binding Path=CanClick}"/&gt;
          &lt;Button Content="Manager Only Click" attachedProperty:SecurityBehavior.IsEnabledRole="Mgr"/&gt;
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>The first button's enabled property is just controlled using the checkbox.
  The second button's enabled property is controlled by an attachedProperty that determines if you are in the correct security group:</p>
  
  <pre><code>    public class SecurityBehavior
  {
      public static readonly DependencyProperty IsEnabledRoleProperty = DependencyProperty.RegisterAttached(
          "IsEnabledRole", typeof (string), typeof (SecurityBehavior), new UIPropertyMetadata(OnIsEnabledRoleChanged));
  
      private static void OnIsEnabledRoleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
      {
          // In here have some logic that determines if the current user is authorised
          // Principal.IsInRole(e.NewValue.ToString() ? true : false;
          sender.SetValue(UIElement.IsEnabledProperty, true);
      }
  
      public static void SetIsEnabledRole(DependencyObject element, string value)
      {
          element.SetValue(IsEnabledRoleProperty, value);
      }
  
      public static string GetIsEnabledRole(DependencyObject element)
      {
          return (string) element.GetValue(IsEnabledRoleProperty);
      }
  }
  </code></pre>
  
  <p>When run both buttons are enabled - the 1st because the checkbox is checked and the second because I am a manager. When I uncheck the checkbox the 1st button is disabled and I want my attached property to be able to only enable if in the correct security group <strong>AND</strong> the checkbox is checked.</p>
  
  <p>How can I change by sample so that I can get have the behavior that sets the IsEnabled based on 2 possible inputs?</p>