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 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); }
void SetTemplate() { #if TODO_XAML var source = new swd.RelativeSource(swd.RelativeSourceMode.FindAncestor, typeof(mwc.TreeViewItem), 1); template1 = new mwc.Data.HierarchicalDataTemplate(typeof(ITreeItem)); template1.VisualTree = WpfListItemHelper.ItemTemplate(LabelEdit, source); template1.ItemsSource = new swd.Binding { Converter = new WpfTreeItemHelper.ChildrenConverter() }; Control.ItemTemplate = template1; template2 = new mwc.Data.HierarchicalDataTemplate(typeof(ITreeItem)); template2.VisualTree = WpfListItemHelper.ItemTemplate(LabelEdit, source); template2.ItemsSource = new swd.Binding { Converter = new WpfTreeItemHelper.ChildrenConverter() }; #endif }