wpf - Expose ToolTip DependencyProperty on custom DataGridTextColumn -
i know can style column , set tooltip way, want have real tooltip property on grid column. having trouble exposing tooltip property textblock before created. custom column.
public class datagridtextcolumn : system.windows.controls.datagridtextcolumn { public static readonly dependencyproperty texttrimmingproperty = dependencyproperty.register( "texttrimming", typeof (texttrimming), typeof (datagridtextcolumn), new propertymetadata(default(texttrimming))); /// <summary> /// horizontalalignment dependency property. /// </summary> public static readonly dependencyproperty horizontalalignmentproperty = dependencyproperty.register( "horizontalalignment", typeof (horizontalalignment), typeof (datagridtextcolumn), new frameworkpropertymetadata(horizontalalignment.left, frameworkpropertymetadataoptions.affectsarrange), validatehorizontalalignmentvalue); public datagridtextcolumn() { elementstyle = application.current.resources["datagridtextstyle"] style; editingelementstyle = application.current.resources["datagrideditingtextstyle"] style; } /// <summary> /// texttrimming, works in read-only mode /// </summary> public texttrimming texttrimming { { return (texttrimming) getvalue(texttrimmingproperty); } set { setvalue(texttrimmingproperty, value); } } /// <summary> /// horizontalalignment property. /// </summary> public horizontalalignment horizontalalignment { { return (horizontalalignment) getvalue(horizontalalignmentproperty); } set { setvalue(horizontalalignmentproperty, value); } } internal static bool validatehorizontalalignmentvalue(object value) { var ha = (horizontalalignment) value; return (ha == horizontalalignment.left || ha == horizontalalignment.center || ha == horizontalalignment.right || ha == horizontalalignment.stretch); } protected override frameworkelement generateelement(datagridcell cell, object dataitem) { var element = (textblock) base.generateelement(cell, dataitem); element.texttrimming = texttrimming; element.horizontalalignment = horizontalalignment; return element; }
the tooltip has attached textblock.
is want:
element.tooltip = new tooltip { content = new textblock { text = "da tooltip!" } };
?...
Comments
Post a Comment