public static sw.FrameworkElementFactory EditableBlock(swd.RelativeSource relativeSource) { var factory = new sw.FrameworkElementFactory(typeof(EditableTextBlock)); var binding = new sw.Data.Binding { Path = TextPath, RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.PropertyChanged }; factory.SetBinding(EditableTextBlock.TextProperty, binding); return factory; }
public static sw.FrameworkElementFactory ItemTemplate(bool editable, swd.RelativeSource relativeSource = null) { var factory = new sw.FrameworkElementFactory(typeof(swc.StackPanel)); factory.SetValue(swc.StackPanel.OrientationProperty, swc.Orientation.Horizontal); factory.AppendChild(ImageBlock()); factory.AppendChild(editable ? EditableBlock(relativeSource) : TextBlock()); return factory; }
public WpfImageTextBindingBlock(Func<IIndirectBinding<string>> textBinding, Func<IIndirectBinding<Image>> imageBinding, bool editable, swd.RelativeSource relativeSource = null) : base(typeof(swc.StackPanel)) { SetValue(swc.StackPanel.OrientationProperty, swc.Orientation.Horizontal); AppendChild(new WpfImageBindingBlock(imageBinding)); if (editable) AppendChild(new WpfEditableTextBindingBlock(textBinding, relativeSource)); else AppendChild(new WpfTextBindingBlock(textBinding)); }
/// <summary> /// Locates the routed event. /// </summary> /// <param name="target">The target.</param> /// <param name="triggerText">The trigger text.</param> /// <returns></returns> protected virtual RoutedEvent GetRoutedEvent(DependencyObject target, string triggerText) { var eventOwner = target.GetType(); if (triggerText.Contains(".")) { var ownerTypeName = triggerText.Substring(0, triggerText.LastIndexOf(".")); triggerText = triggerText.Substring(ownerTypeName.Length + 1); var assemblies = GetSearchableAssemblies().ToList(); var nhddl = new[] { "HibernatingRhinos.Profiler.Appender", "Mono.Cecil.Pdb", "Mono.Cecil.Mdb","System.Web.Services", "System.ServiceModel", "Caliburn.ModelFramework", "WPFToolkit" }; foreach (var nh in nhddl) { var hasnh = assemblies.FirstOrDefault(o => o.FullName.Contains(nh)); if (hasnh == null) break; assemblies.Remove(hasnh); } #if NET35 var types = assemblies.SelectMany(a => a.GetExportedTypes()) .Where(x => _dependencyObjectType.IsAssignableFrom(x) || (x.IsAbstract && x.IsSealed || typeof(Binding).IsAssignableFrom(x))); #endif #if NET40 var types = assemblies.Where(a => a.GetType().FullName == "System.Reflection.RuntimeAssembly").SelectMany(a => a.GetExportedTypes()) .Where(x => _dependencyObjectType.IsAssignableFrom(x) || (x.IsAbstract && x.IsSealed)); #endif eventOwner = types.Where(t => t.FullName.Equals(ownerTypeName)).FirstOrDefault() ?? types.Where(t => t.Name.Equals(ownerTypeName)).FirstOrDefault(); if (eventOwner == null) throw new CaliburnException("Type " + ownerTypeName + " not found."); } var fieldEventProp = eventOwner.GetField(triggerText + "Event", BindingFlags.Static | BindingFlags.Public); if (fieldEventProp == null) throw new CaliburnException(triggerText + " event was not found on type " + eventOwner.Name + "."); if (!typeof(RoutedEvent).IsAssignableFrom(fieldEventProp.FieldType)) throw new CaliburnException(triggerText + " event was not found on type " + eventOwner.Name + "."); return (RoutedEvent)fieldEventProp.GetValue(null); }
public WpfEditableTextBindingBlock(Func<IIndirectBinding<string>> getBinding, swd.RelativeSource relativeSource) : base(typeof(EditableTextBlock)) { //var binding = new sw.Data.Binding { Path = TextPath, RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.PropertyChanged }; //SetBinding(EditableTextBlock.TextProperty, binding); }