/// <summary> /// Applies the behavior to the specified view. /// </summary> /// <param name="view">The view.</param> public void ApplyTo(DependencyObject view) { var element = view.FindName(elementDescription.Name); if (dependencyProperty != null && !element.HasBinding(dependencyProperty)) { var binding = new Binding(path) { Mode = mode, Converter = converter }; var bindableProperty = elementDescription.Convention .EnsureBindableProperty(element, dependencyProperty); TryAddValidation(element, binding, bindableProperty); CheckTextBox(element, binding, bindableProperty); element.SetBinding(bindableProperty, binding); Log.Info("Applied data binding {0} to {1}.", binding, view); } if(!checkTemplate) return; var itemsControl = (ItemsControl)element; if (NeedsItemTemplate(itemsControl)) { itemsControl.ItemTemplate = CreateTemplate(itemsControl); Log.Info("Applied item template to {0}.", view); } }
/// <summary> /// Applies the behavior to the specified view. /// </summary> /// <param name="view">The view.</param> public void ApplyTo(DependencyObject view) { var element = view.FindName(elementName); if(!string.IsNullOrEmpty(actionTargetPath)) { var binding = new Binding(actionTargetPath); element.SetBinding(Action.TargetProperty, binding); } Message.SetAttach(element, message); Log.Info("Attached message {0} to {1}.", message, view); }