clean up DIYGrid TextColumn (mimic recent changes in HyperlinkColumn)
This commit is contained in:
1 parent
1bbe8d0af3
commit
3d27735006
2 files changed
+32
-25
No files matched your search
@@ -650,12 +650,13 @@ namespace mbts.spark {
|
||||
ListSortDirection? _cached_sort_direction;
|
||||
|
||||
public OrderBookLastMessageColumn(IDataGridColumnPersistentFilter<OrderSecurityRootPair, string> filter)
|
||||
: base(Columns.LastMessage, new Binding(nameof(OrderBookRowVM.last_msg)), filter, DataGridFilterKnownTemplates.Regex) {
|
||||
: base(Columns.LastMessage, filter, DataGridFilterKnownTemplates.Regex) {
|
||||
id = key.ToString();
|
||||
this.filter = filter;
|
||||
Header = "Last Message";
|
||||
Width = DefaultColumnWidths.LastMessage;
|
||||
tooltip_binding = new Binding(nameof(OrderBookRowVM.last_msg));
|
||||
TextBinding = new Binding(nameof(OrderBookRowVM.last_msg));
|
||||
ToolTipBinding = new Binding(nameof(OrderBookRowVM.last_msg));
|
||||
}
|
||||
|
||||
public new IDataGridColumnPersistentFilter<OrderSecurityRootPair, string> filter { get; }
|
||||
|
||||
+29
-23
@@ -1,44 +1,50 @@
|
||||
using mbts.spark.filters;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
partial class DIYGrid {
|
||||
internal class TextColumn<TColKey> : FrameworkElementColumnBase<TColKey>, IFilterableColumn {
|
||||
readonly BindingBase _binding;
|
||||
internal class TextColumn<TKey> : FrameworkElementColumnBase<TKey>, IFrameworkElementColumn, IFilterableColumn, IKeyedColumn<TKey> {
|
||||
static readonly Thickness _default_padding = new Thickness(6, 0, 6, 0);
|
||||
|
||||
public TextColumn(TColKey key, BindingBase binding, IDataGridColumnFilter filter, string filter_template) : base(key) {
|
||||
public TextColumn(
|
||||
TKey key, IDataGridColumnFilter filter, string filter_template) : base(key) {
|
||||
this.filter = filter;
|
||||
this.filter_template = filter_template;
|
||||
_binding = binding;
|
||||
}
|
||||
|
||||
public Style ElementStyle { get; set; }
|
||||
public IDataGridColumnFilter filter { get; }
|
||||
public string filter_template { get; }
|
||||
public BindingBase background_binding { get; set; }
|
||||
public BindingBase font_weight_binding { get; set; }
|
||||
public BindingBase foreground_binding { get; set; }
|
||||
public BindingBase tooltip_binding { get; set; }
|
||||
public VerticalAlignment vertical_alignment { get; set; } = VerticalAlignment.Center;
|
||||
public Thickness padding { get; set; } = _default_padding;
|
||||
// bindings
|
||||
public BindingBase TextBinding { get; set; }
|
||||
public BindingBase ToolTipBinding { get; set; }
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
var v = new TextCell { Foreground = font_brush, VerticalAlignment = vertical_alignment };
|
||||
v.SetBinding(TextCell.TextProperty, _binding);
|
||||
var v = new TextCell {
|
||||
Padding = padding
|
||||
};
|
||||
// bindings
|
||||
if (TextBinding != null)
|
||||
v.SetBinding(TextCell.TextProperty, TextBinding);
|
||||
if (ToolTipBinding != null)
|
||||
v.SetBinding(ToolTipProperty, ToolTipBinding);
|
||||
v.SetBinding(TextCell.ForegroundProperty, new Binding(nameof(font_brush)) { Source = this });
|
||||
v.SetBinding(TextCell.FontFamilyProperty, new Binding(nameof(font_family)) { Source = this });
|
||||
v.SetBinding(TextCell.FontSizeProperty, new Binding(nameof(font_size)) { Source = this });
|
||||
v.SetBinding(TextCell.HorizontalAlignmentProperty, new Binding(nameof(horizontal_alignment)) { Source = this });
|
||||
v.SetBinding(TextCell.WidthProperty, new Binding(nameof(ActualWidth)) { Source = this });
|
||||
try_set_binding(TextCell.BackgroundProperty, background_binding);
|
||||
try_set_binding(TextCell.ForegroundProperty, foreground_binding);
|
||||
try_set_binding(TextCell.FontWeightProperty, font_weight_binding);
|
||||
try_set_binding(TextCell.ToolTipProperty, tooltip_binding);
|
||||
v.SetBinding(TextCell.HorizontalContentAlignmentProperty, new Binding(nameof(horizontal_alignment)) { Source = this });
|
||||
v.SetBinding(FrameworkElement.WidthProperty, new Binding(nameof(ActualWidth)) { Source = this });
|
||||
// background
|
||||
var bg_brush = new SolidColorBrush();
|
||||
BindingOperations.SetBinding(bg_brush, SolidColorBrush.ColorProperty, new Binding(nameof(background_color)) { Source = this });
|
||||
v.Background = bg_brush;
|
||||
// style
|
||||
if (ElementStyle != null)
|
||||
v.Style = ElementStyle;
|
||||
return v;
|
||||
//
|
||||
void try_set_binding(DependencyProperty p, BindingBase b) {
|
||||
if (b != null)
|
||||
v.SetBinding(p, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user