WindowState = Maximized を設定すると、奇妙なエラーが発生します (Normal に設定してから全画面表示にすると正常に動作します!!)。デバッグは私に厄介な例外を与え、ここでいくつかのポインタを取得したいと思っていました.
例外:
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=SyntaxHighlight
StackTrace:
at SyntaxHighlight.SyntaxHighlightBox.<.ctor>b__0(Object s, RoutedEventArgs e) in
C:\Test\SyntaxHighlight\src\SyntaxHighlightBox.xaml.cs:line 67
SyntaxHighlighBox.xaml.cs
public SyntaxHighlightBox() {
InitializeComponent();
MaxLineCountInBlock = 100;
LineHeight = FontSize * 1.3;
totalLineCount = 1;
blocks = new List<InnerTextBlock>();
Loaded += (s, e) => {
renderCanvas = (DrawingControl)Template.FindName("PART_RenderCanvas", this);
lineNumbersCanvas = (DrawingControl)Template.FindName("PART_LineNumbersCanvas", this);
scrollViewer = (ScrollViewer)Template.FindName("PART_ContentHost", this);
lineNumbersCanvas.Width = GetFormattedTextWidth(string.Format("{0:0000}", totalLineCount)) + 5;
scrollViewer.ScrollChanged += OnScrollChanged;
InvalidateBlocks(0);
InvalidateVisual();
};
SizeChanged += (s, e) => {
if (e.HeightChanged == false)
return;
UpdateBlocks();
InvalidateVisual();
};