Selaa lähdekoodia

Added tooltips for columns, brought from the ToolTip on the editor

Kenric Nugteren 7 kuukautta sitten
vanhempi
commit
0329124f21
1 muutettua tiedostoa jossa 18 lisäystä ja 10 poistoa
  1. 18 10
      inabox.wpf/DynamicGrid/UIComponent/DynamicGridGridUIComponent.cs

+ 18 - 10
inabox.wpf/DynamicGrid/UIComponent/DynamicGridGridUIComponent.cs

@@ -683,18 +683,24 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
 
     private void DataGrid_CellToolTipOpening(object? sender, GridCellToolTipOpeningEventArgs e)
     {
-        if (GetColumn(e.RowColumnIndex.ColumnIndex) is not DynamicActionColumn col)
-            return;
-        var toolTip = col.ToolTip;
-        if (toolTip is null)
-            return;
+        var column = GetColumn(e.RowColumnIndex.ColumnIndex);
+        if (column is DynamicActionColumn ac)
+        {
+            var toolTip = ac.ToolTip;
+            if (toolTip is null)
+                return;
 
-        var row = GetRowFromIndex(e.RowColumnIndex.RowIndex);
+            var row = GetRowFromIndex(e.RowColumnIndex.RowIndex);
 
-        e.ToolTip.Template = TemplateGenerator.CreateControlTemplate(
-            typeof(ToolTip),
-            () => toolTip.Invoke(col, row)
-        );
+            e.ToolTip.Template = TemplateGenerator.CreateControlTemplate(
+                typeof(ToolTip),
+                () => toolTip.Invoke(ac, row)
+            );
+        }
+        else if(column is DynamicGridColumn gc)
+        {
+            e.ToolTip.Content = gc.Editor.ToolTip;
+        }
     }
     public void AddVisualFilter(string column, string value, FilterType filtertype = FilterType.Contains)
     {
@@ -1278,6 +1284,8 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
             
             newColumn.HeaderStyle = GetHeaderCellStyle(column);
 
+            newColumn.ShowHeaderToolTip = !column.Editor.ToolTip.IsNullOrWhiteSpace();
+
             var cellstyle = GetCellStyle(column);
             if (Parent.IsDirectEditMode())
             {