Following i have written:
DataTemplate TabItemColumnHeaderTemplate_GV = new DataTemplate(typeof(DataGridTextColumn)); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(Border)); factory.SetBinding(Border.ToolTipProperty, new Binding() {Path = new PropertyPath(Classes.AttachedProperties.TabItemColumnToolTipAP), RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) }); FrameworkElementFactory factory2 = new FrameworkElementFactory(typeof(TextBlock)); factory2.SetBinding(TextBlock.TextProperty, new Binding("Content") { RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) }); factory.AddHandler(Border.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(TabItemColumnHeader_PreviewMouseRightButtonDown)); factory.AppendChild(factory2); TabItemColumnHeaderTemplate_GV.VisualTree = factory; DataGridTextColumn column = new DataGridTextColumn(); column.HeaderTemplate = TabItemColumnHeaderTemplate_GV; column.SetValue(Classes.AttachedProperties.TabItemColumnToolTipAP, "Common"); column.Header = "Extension"; column.Binding = new Binding("_FileExtension"); column.CanUserSort = true; column.SortMemberPath = "Extension"; grid.Columns.Add(column);I don't know how to refer from the HeaderTemplate to the AttachedProperty of the column. The Shown Binding of the Borders ToolTip to the AttachedProperty of the Column doesn't work. Logo, i think , cause the real host of the template is not the column itself, instead the Header of the column works as hostitem. But i can't set an attachedProperty on a header, so, has anybody an idea how to handle my problem??