|
@@ -940,7 +940,8 @@ namespace InABox.DynamicGrid
|
|
|
row[scol] = corerow[column.ColumnName];
|
|
|
}
|
|
|
|
|
|
- for (var i = 0; i < ActionColumns.Count; i++) row[string.Format("ActionColumn{0}", i)] = ActionColumns[i].Image.Invoke(corerow);
|
|
|
+ for (var i = 0; i < ActionColumns.Count; i++)
|
|
|
+ row[string.Format("ActionColumn{0}", i)] = ActionColumns[i].Data(corerow);
|
|
|
}
|
|
|
|
|
|
private void DataGrid_QueryRowHeight(object? sender, QueryRowHeightEventArgs e)
|
|
@@ -1343,61 +1344,107 @@ namespace InABox.DynamicGrid
|
|
|
//String sColName = String.Format("ActionColumn{0}{1}", i, position == DynamicActionColumnPosition.Start ? "L" : "R");
|
|
|
var sColName = string.Format("ActionColumn{0}", i);
|
|
|
gridRowResizingOptions.ExcludeColumns.Add(sColName);
|
|
|
-
|
|
|
- var newcol = new GridImageColumn();
|
|
|
- newcol.MappingName = sColName;
|
|
|
- //newcol.Stretch = Stretch.Uniform;
|
|
|
- newcol.Width = column.Width == 0 ? DataGrid.RowHeight : column.Width;
|
|
|
- newcol.Padding = new Thickness(4);
|
|
|
- newcol.ImageHeight = DataGrid.RowHeight - 8;
|
|
|
- newcol.ImageWidth = DataGrid.RowHeight - 8;
|
|
|
- newcol.ColumnSizer = GridLengthUnitType.None;
|
|
|
- newcol.HeaderText = column.HeaderText;
|
|
|
- newcol.AllowFiltering = column.Filters != null && column.Filters.Any();
|
|
|
- newcol.AllowSorting = false;
|
|
|
- newcol.FilterRowOptionsVisibility = Visibility.Collapsed;
|
|
|
- newcol.ShowToolTip = column.ToolTip != null;
|
|
|
-
|
|
|
-
|
|
|
- var style = new Style();
|
|
|
- style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
- style.Setters.Add(new Setter(IsEnabledProperty, false));
|
|
|
- newcol.FilterRowCellStyle = style;
|
|
|
-
|
|
|
|
|
|
- var headstyle = new Style(typeof(GridHeaderCellControl));
|
|
|
- headstyle.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
- headstyle.Setters.Add(new Setter(ForegroundProperty, new SolidColorBrush(Colors.Black)));
|
|
|
- headstyle.Setters.Add(new Setter(FontSizeProperty, 12D));
|
|
|
- if (!string.IsNullOrWhiteSpace(column.HeaderText))
|
|
|
+ if (column is DynamicImageColumn imgcol)
|
|
|
{
|
|
|
- //headstyle.Setters.Add(new Setter(LayoutTransformProperty, new RotateTransform(270.0F)));
|
|
|
- headstyle.Setters.Add(new Setter(BorderThicknessProperty, new Thickness(0.0, 0.0, 0, 0)));
|
|
|
- headstyle.Setters.Add(new Setter(MarginProperty, new Thickness(0, 0, 0.75, 0.75)));
|
|
|
- headstyle.Setters.Add(new Setter(TemplateProperty, Application.Current.Resources["VerticalColumnHeader"] as ControlTemplate));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var image = column.Image?.Invoke(null);
|
|
|
- if (image != null)
|
|
|
+ var newcol = new GridImageColumn();
|
|
|
+ newcol.MappingName = sColName;
|
|
|
+ //newcol.Stretch = Stretch.Uniform;
|
|
|
+ newcol.Width = column.Width == 0 ? DataGrid.RowHeight : column.Width;
|
|
|
+ newcol.Padding = new Thickness(4);
|
|
|
+ newcol.ImageHeight = DataGrid.RowHeight - 8;
|
|
|
+ newcol.ImageWidth = DataGrid.RowHeight - 8;
|
|
|
+ newcol.ColumnSizer = GridLengthUnitType.None;
|
|
|
+ newcol.HeaderText = column.HeaderText;
|
|
|
+
|
|
|
+ ApplyFilterStyle(newcol, true);
|
|
|
+
|
|
|
+ newcol.ShowToolTip = column.ToolTip != null;
|
|
|
+
|
|
|
+ var style = new Style();
|
|
|
+ style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
+ style.Setters.Add(new Setter(IsEnabledProperty, false));
|
|
|
+ newcol.FilterRowCellStyle = style;
|
|
|
+
|
|
|
+ var headstyle = new Style(typeof(GridHeaderCellControl));
|
|
|
+ headstyle.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
+ headstyle.Setters.Add(new Setter(ForegroundProperty, new SolidColorBrush(Colors.Black)));
|
|
|
+ headstyle.Setters.Add(new Setter(FontSizeProperty, 12D));
|
|
|
+ if (!string.IsNullOrWhiteSpace(column.HeaderText))
|
|
|
{
|
|
|
- var template = new ControlTemplate(typeof(GridHeaderCellControl));
|
|
|
- var border = new FrameworkElementFactory(typeof(Border));
|
|
|
- border.SetValue(Border.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro));
|
|
|
- border.SetValue(Border.PaddingProperty, new Thickness(4));
|
|
|
- border.SetValue(MarginProperty, new Thickness(0, 0, 1, 1));
|
|
|
- var img = new FrameworkElementFactory(typeof(Image));
|
|
|
- img.SetValue(Image.SourceProperty, image);
|
|
|
- border.AppendChild(img);
|
|
|
- template.VisualTree = border;
|
|
|
- headstyle.Setters.Add(new Setter(TemplateProperty, template));
|
|
|
+ //headstyle.Setters.Add(new Setter(LayoutTransformProperty, new RotateTransform(270.0F)));
|
|
|
+ headstyle.Setters.Add(new Setter(BorderThicknessProperty, new Thickness(0.0, 0.0, 0, 0)));
|
|
|
+ headstyle.Setters.Add(new Setter(MarginProperty, new Thickness(0, 0, 0.75, 0.75)));
|
|
|
+ headstyle.Setters.Add(new Setter(TemplateProperty,
|
|
|
+ Application.Current.Resources["VerticalColumnHeader"] as ControlTemplate));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var image = imgcol.Image?.Invoke(null);
|
|
|
+ if (image != null)
|
|
|
+ {
|
|
|
+ var template = new ControlTemplate(typeof(GridHeaderCellControl));
|
|
|
+ var border = new FrameworkElementFactory(typeof(Border));
|
|
|
+ border.SetValue(Border.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro));
|
|
|
+ border.SetValue(Border.PaddingProperty, new Thickness(4));
|
|
|
+ border.SetValue(MarginProperty, new Thickness(0, 0, 1, 1));
|
|
|
+ var img = new FrameworkElementFactory(typeof(Image));
|
|
|
+ img.SetValue(Image.SourceProperty, image);
|
|
|
+ border.AppendChild(img);
|
|
|
+ template.VisualTree = border;
|
|
|
+ headstyle.Setters.Add(new Setter(TemplateProperty, template));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- newcol.HeaderStyle = headstyle;
|
|
|
+ newcol.HeaderStyle = headstyle;
|
|
|
|
|
|
- DataGrid.Columns.Add(newcol);
|
|
|
- ColumnList.Add(column);
|
|
|
+ DataGrid.Columns.Add(newcol);
|
|
|
+ ColumnList.Add(column);
|
|
|
+ }
|
|
|
+ else if (column is DynamicTextColumn txtCol)
|
|
|
+ {
|
|
|
+
|
|
|
+ var newcol = new GridTextColumn();
|
|
|
+ gridRowResizingOptions.ExcludeColumns.Add(sColName);
|
|
|
+ newcol.TextWrapping = TextWrapping.NoWrap;
|
|
|
+
|
|
|
+ newcol.TextAlignment = txtCol.Alignment == Alignment.NotSet
|
|
|
+ ? TextAlignment.Left
|
|
|
+ : txtCol.Alignment == Alignment.BottomLeft || txtCol.Alignment == Alignment.MiddleLeft ||
|
|
|
+ txtCol.Alignment == Alignment.TopLeft
|
|
|
+ ? TextAlignment.Left
|
|
|
+ : txtCol.Alignment == Alignment.BottomCenter || txtCol.Alignment == Alignment.MiddleCenter ||
|
|
|
+ txtCol.Alignment == Alignment.TopCenter
|
|
|
+ ? TextAlignment.Center
|
|
|
+ : TextAlignment.Right;
|
|
|
+
|
|
|
+ newcol.AllowEditing = false;
|
|
|
+ newcol.UpdateTrigger = UpdateSourceTrigger.PropertyChanged;
|
|
|
+ newcol.MappingName = sColName;
|
|
|
+ newcol.Width = column.Width == 0 ? DataGrid.RowHeight : column.Width;
|
|
|
+ newcol.ColumnSizer = GridLengthUnitType.None;
|
|
|
+ newcol.HeaderText = column.HeaderText;
|
|
|
+ newcol.AllowFiltering = column.Filters != null && column.Filters.Any();
|
|
|
+ newcol.AllowSorting = false;
|
|
|
+ newcol.FilterRowOptionsVisibility = Visibility.Collapsed;
|
|
|
+ newcol.ShowToolTip = column.ToolTip != null;
|
|
|
+
|
|
|
+ var style = new Style();
|
|
|
+ style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
+ style.Setters.Add(new Setter(IsEnabledProperty, false));
|
|
|
+ newcol.FilterRowCellStyle = style;
|
|
|
+
|
|
|
+ var headstyle = new Style(typeof(GridHeaderCellControl));
|
|
|
+ headstyle.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
+ headstyle.Setters.Add(new Setter(ForegroundProperty, new SolidColorBrush(Colors.Black)));
|
|
|
+ headstyle.Setters.Add(new Setter(FontSizeProperty, 12D));
|
|
|
+ newcol.HeaderStyle = headstyle;
|
|
|
+
|
|
|
+ DataGrid.Columns.Add(newcol);
|
|
|
+ ColumnList.Add(column);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1648,29 +1695,7 @@ namespace InABox.DynamicGrid
|
|
|
: HorizontalAlignment.Right;
|
|
|
|
|
|
|
|
|
- var filterstyle = new Style();
|
|
|
- if (filtering)
|
|
|
- {
|
|
|
- filterstyle.Setters.Add(new Setter(BackgroundProperty, BaseDynamicGrid.FilterBackground));
|
|
|
- newcol.ImmediateUpdateColumnFilter = true;
|
|
|
- newcol.ColumnFilter = ColumnFilter.Value;
|
|
|
- newcol.FilterRowCondition = FilterRowCondition.Contains;
|
|
|
- newcol.FilterRowOptionsVisibility = Visibility.Collapsed;
|
|
|
- newcol.AllowBlankFilters = true;
|
|
|
- newcol.AllowSorting = CanSort();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- filterstyle.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
- filterstyle.Setters.Add(new Setter(IsEnabledProperty, false));
|
|
|
- newcol.ColumnFilter = ColumnFilter.Value;
|
|
|
- newcol.AllowFiltering = false;
|
|
|
- newcol.AllowSorting = false;
|
|
|
- newcol.FilterRowEditorType = "TextBox";
|
|
|
- newcol.FilterRowOptionsVisibility = Visibility.Collapsed;
|
|
|
- }
|
|
|
-
|
|
|
- newcol.FilterRowCellStyle = filterstyle;
|
|
|
+ ApplyFilterStyle(newcol,filtering);
|
|
|
|
|
|
|
|
|
var headstyle = new Style(typeof(GridHeaderCellControl));
|
|
@@ -1739,6 +1764,33 @@ namespace InABox.DynamicGrid
|
|
|
ResizeColumns(DataGrid, DataGrid.ActualWidth - 2, DataGrid.ActualHeight - 2);
|
|
|
}
|
|
|
|
|
|
+ private void ApplyFilterStyle(GridColumn column, bool filtering)
|
|
|
+ {
|
|
|
+ var filterstyle = new Style();
|
|
|
+ if (filtering)
|
|
|
+ {
|
|
|
+ filterstyle.Setters.Add(new Setter(BackgroundProperty, BaseDynamicGrid.FilterBackground));
|
|
|
+ column.ImmediateUpdateColumnFilter = true;
|
|
|
+ column.ColumnFilter = ColumnFilter.Value;
|
|
|
+ column.FilterRowCondition = FilterRowCondition.Contains;
|
|
|
+ column.FilterRowOptionsVisibility = Visibility.Collapsed;
|
|
|
+ column.AllowBlankFilters = true;
|
|
|
+ column.AllowSorting = CanSort();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ filterstyle.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
|
+ filterstyle.Setters.Add(new Setter(IsEnabledProperty, false));
|
|
|
+ column.ColumnFilter = ColumnFilter.Value;
|
|
|
+ column.AllowFiltering = false;
|
|
|
+ column.AllowSorting = false;
|
|
|
+ column.FilterRowEditorType = "TextBox";
|
|
|
+ column.FilterRowOptionsVisibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+
|
|
|
+ column.FilterRowCellStyle = filterstyle;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region Refresh / Reload
|
|
@@ -1974,7 +2026,7 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
var rowdata = new List<object?>(row.Values);
|
|
|
foreach (var ac in ActionColumns)
|
|
|
- rowdata.Add(ac.Image.Invoke(row));
|
|
|
+ rowdata.Add(ac.Data(row));
|
|
|
|
|
|
var datarow = DataGridItems.Rows[row.Index];
|
|
|
for (var i = 0; i < rowdata.Count; i++)
|
|
@@ -1999,7 +2051,11 @@ namespace InABox.DynamicGrid
|
|
|
}
|
|
|
|
|
|
for (var i = 0; i < ActionColumns.Count; i++)
|
|
|
- result.Columns.Add(string.Format("ActionColumn{0}", i), typeof(BitmapImage));
|
|
|
+ result.Columns.Add(string.Format("ActionColumn{0}", i),
|
|
|
+ ActionColumns[i] is DynamicImageColumn
|
|
|
+ ? typeof(BitmapImage)
|
|
|
+ : typeof(String)
|
|
|
+ );
|
|
|
|
|
|
foreach (var row in Data.Rows)
|
|
|
{
|
|
@@ -2059,7 +2115,7 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
var rowdata = new List<object?>(row.Values);
|
|
|
foreach (var ac in ActionColumns)
|
|
|
- rowdata.Add(ac.Image.Invoke(row));
|
|
|
+ rowdata.Add(ac.Data(row));
|
|
|
|
|
|
try
|
|
|
{
|