简体   繁体   中英

Can I get the value of one attached property from another?

If I have two attached properties on a single object

  1. Source
  2. Target

Is it possible to query the value of the source attached property from the property changed method of the target property, or is it that they do not have any knowledge of each other?

Sure, I do this all the time for attached ICommand properties where I need to retrieve an CommandParameter object.

Eg:

private static void HandleKeyDown(object sender, KeyEventArgs e)
{
  var param = sender.GetValue(CommmandParameterProperty);
  GetKeyDownCommand((UIElement)sender).Execute(param);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM