private bool Logic_ProvideValue(ObjectWriterContext ctx) { MarkupExtension currentInstance = (MarkupExtension) ctx.CurrentInstance; object parentInstance = ctx.ParentInstance; XamlMember parentProperty = ctx.ParentProperty; if ((parentProperty != null) && !parentProperty.IsUnknown) { XamlType declaringType = null; if (parentProperty.IsAttachable) { declaringType = parentProperty.DeclaringType; } else { declaringType = ctx.ParentType; } if ((declaringType != null) && (declaringType.SetMarkupExtensionHandler != null)) { XamlSetMarkupExtensionEventArgs e = new XamlSetMarkupExtensionEventArgs(parentProperty, currentInstance, ctx.ServiceProviderContext, parentInstance) { CurrentType = declaringType }; declaringType.SetMarkupExtensionHandler(parentInstance, e); if (e.Handled) { return true; } } } object obj4 = currentInstance; if ((ctx.LiveDepth != 1) || !this._skipProvideValueOnRoot) { obj4 = this.Runtime.CallProvideValue(currentInstance, ctx.ServiceProviderContext); } if (ctx.ParentProperty != null) { if (obj4 != null) { if (!(obj4 is NameFixupToken)) { ctx.CurrentType = this.GetXamlType(obj4.GetType()); } } else if (ctx.ParentProperty == XamlLanguage.Items) { ctx.CurrentType = ctx.ParentType.ItemType; } else { ctx.CurrentType = ctx.ParentProperty.Type; } ctx.CurrentInstance = obj4; } else { ctx.CurrentInstance = obj4; } return false; }
public static void ReceiveMarkupExtension(object targetObject, XamlSetMarkupExtensionEventArgs eventArgs) { if (targetObject == null) { throw new ArgumentNullException("targetObject"); } if (eventArgs == null) { throw new ArgumentNullException("eventArgs"); } Condition condition = targetObject as Condition; if (condition != null && eventArgs.Member.Name == "Binding" && eventArgs.MarkupExtension is BindingBase) { condition.Binding = eventArgs.MarkupExtension as BindingBase; eventArgs.Handled = true; } }
public static void ReceiveMarkupExtension(object targetObject, XamlSetMarkupExtensionEventArgs eventArgs) { if (targetObject == null) { throw new ArgumentNullException("targetObject"); } if (eventArgs == null) { throw new ArgumentNullException("eventArgs"); } Setter setter = targetObject as Setter; if (setter == null || eventArgs.Member.Name != "Value") { return; } MarkupExtension me = eventArgs.MarkupExtension; if (me is StaticResourceExtension) { var sr = me as StaticResourceExtension; setter.Value = sr.ProvideValueInternal(eventArgs.ServiceProvider, true /*allowDeferedReference*/); eventArgs.Handled = true; } else if (me is DynamicResourceExtension || me is BindingBase) { setter.Value = me; eventArgs.Handled = true; } }
// must be static public void HandleMarkupExtension (object o, XamlSetMarkupExtensionEventArgs a) { }
public static void ReceiveMarkupExtension(object targetObject, XamlSetMarkupExtensionEventArgs eventArgs) { if (targetObject == null) { throw new ArgumentNullException("targetObject"); } if (eventArgs == null) { throw new ArgumentNullException("eventArgs"); } DataTrigger trigger = targetObject as DataTrigger; if (trigger != null && eventArgs.Member.Name == "Binding" && eventArgs.MarkupExtension is BindingBase) { trigger.Binding = eventArgs.MarkupExtension as BindingBase; eventArgs.Handled = true; } else { eventArgs.CallBase(); } }