Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

can i set the tooltip property of an DataGridtextcolumn header to an AttachedProperty?

$
0
0

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??

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>