public static HasTargetSet ( global::Xamarin.Forms.BindableObject element ) : bool | ||
element | global::Xamarin.Forms.BindableObject | DependencyObject to check |
return | bool |
private void ElementLoaded() { UpdateContext(); UIElement currentElement; if (context.View == null) { currentElement = AssociatedObject; while (currentElement != null) { if (Action.HasTargetSet(currentElement)) { break; } currentElement = currentElement.Parent; } } else { currentElement = context.View as FrameworkElement; } Handler = currentElement; }
void ElementLoaded(object sender, RoutedEventArgs e) { UpdateContext(); DependencyObject currentElement; if (context.View == null) { currentElement = AssociatedObject; while (currentElement != null) { if (Action.HasTargetSet(currentElement)) { break; } currentElement = BindingScope.GetVisualParent(currentElement); } } else { currentElement = context.View; } #if NET || NETCORE var binding = new Binding { Path = new PropertyPath(Message.HandlerProperty), Source = currentElement }; #elif WINDOWS_UWP var binding = new Binding { Source = currentElement }; #elif NET5_0_WINDOWS const string bindingText = "<Binding xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation\' xmlns:cal='clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform' Path='(cal:Message.Handler)' />"; StringReader stringReader = new StringReader(bindingText); XmlReader xmlReader = XmlReader.Create(stringReader); var binding = (Binding)XamlReader.Load(xmlReader); binding.Source = currentElement; #else const string bindingText = "<Binding xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation\' xmlns:cal='clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform' Path='(cal:Message.Handler)' />"; var binding = (Binding)XamlReader.Load(bindingText); binding.Source = currentElement; #endif BindingOperations.SetBinding(this, HandlerProperty, binding); }
void ElementLoaded(object sender, RoutedEventArgs e) { UpdateContext(); #if !WP7 DependencyObject currentElement; if (context.View == null) { currentElement = AssociatedObject; while (currentElement != null) { if (Action.HasTargetSet(currentElement)) { break; } currentElement = VisualTreeHelper.GetParent(currentElement); } } else { currentElement = context.View; } #if NET var binding = new Binding { Path = new PropertyPath(Message.HandlerProperty), Source = currentElement }; #else const string bindingText = "<Binding xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation\' xmlns:cal='clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro' Path='(cal:Message.Handler)' />"; var binding = (Binding)XamlReader.Load(bindingText); binding.Source = currentElement; #endif BindingOperations.SetBinding(this, HandlerProperty, binding); #endif }