SPARK-2377 OB Last Message column displays strange alignment when resizing and/or scrolling
This commit is contained in:
1 parent
ab3fa25709
commit
9b6064e87e
2 files changed
+20
-4
No files matched your search
@@ -20,16 +20,25 @@ namespace mbts.ui.controls {
|
||||
GlyphRun _glyph_run;
|
||||
GlyphContext _glyph_context;
|
||||
|
||||
static TextCell() =>
|
||||
static TextCell() {
|
||||
WPFHelper.override_metadata<HorizontalAlignment, TextCell>(
|
||||
HorizontalAlignmentProperty,
|
||||
FrameworkPropertyMetadataOptions.AffectsArrange |
|
||||
FrameworkPropertyMetadataOptions.AffectsMeasure |
|
||||
FrameworkPropertyMetadataOptions.AffectsRender,
|
||||
(o, v) => {
|
||||
o._horizontal_alignment = v;
|
||||
o._glyph_run = null;
|
||||
},
|
||||
HorizontalAlignment.Left);
|
||||
WPFHelper.override_metadata<double, TextCell>(
|
||||
WidthProperty,
|
||||
FrameworkPropertyMetadataOptions.AffectsArrange |
|
||||
FrameworkPropertyMetadataOptions.AffectsMeasure |
|
||||
FrameworkPropertyMetadataOptions.AffectsRender,
|
||||
(o, v) => o._glyph_run = null,
|
||||
double.NaN);
|
||||
}
|
||||
|
||||
public TextCell() {
|
||||
_background = Background;
|
||||
@@ -162,10 +171,15 @@ namespace mbts.ui.controls {
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext) {
|
||||
var rs = RenderSize;
|
||||
var rect = new Rect(0, 0, rs.Width, rs.Height);
|
||||
if (_background != null)
|
||||
drawingContext.DrawRectangle(_background, null, new Rect(RenderSize));
|
||||
if (_glyph_run != null)
|
||||
drawingContext.DrawRectangle(_background, null, rect);
|
||||
if (_glyph_run != null) {
|
||||
drawingContext.PushClip(new RectangleGeometry(rect));
|
||||
drawingContext.DrawGlyphRun(_foreground, _glyph_run);
|
||||
drawingContext.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -22,10 +22,12 @@ namespace mbts.ui.controls {
|
||||
public VerticalAlignment vertical_alignment { get; set; } = VerticalAlignment.Center;
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
var v = new TextCell { Foreground = font_brush, HorizontalAlignment = horizontal_alignment, VerticalAlignment = vertical_alignment };
|
||||
var v = new TextCell { Foreground = font_brush, VerticalAlignment = vertical_alignment };
|
||||
v.SetBinding(TextCell.TextProperty, _binding);
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user