static TriggerBase CreateTrigger(Type targetType, string[] triggerPlusMessage) { if (triggerPlusMessage.Length == 1) { var defaults = ConventionManager.GetElementConvention(targetType); return(defaults.CreateTrigger()); } var triggerDetail = triggerPlusMessage[0] .Replace("[", string.Empty) .Replace("]", string.Empty) .Replace("Event", string.Empty) .Trim(); return(new EventTrigger { EventName = triggerDetail }); }
private static void BindParameter(FrameworkElement target, Parameter parameter, string elementName, string path, BindingMode bindingMode) { var element = elementName == "$this" ? target : ExtensionMethods.GetNamedElementsInScope(target).FindName(elementName); if (element == null) { return; } if (string.IsNullOrEmpty(path)) { path = ConventionManager.GetElementConvention(element.GetType()).ParameterProperty; } var binding = new Binding(path) { Source = element, Mode = bindingMode }; #if SILVERLIGHT var expression = (BindingExpression)BindingOperations.SetBinding(parameter, Parameter.ValueProperty, binding); var field = element.GetType().GetField(path + "Property", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); if (field == null) { return; } ConventionManager.ApplySilverlightTriggers(element, (DependencyProperty)field.GetValue(null), x => expression); #else binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; BindingOperations.SetBinding(parameter, Parameter.ValueProperty, binding); #endif }