データフィールド値を使用してテキストブロックをレンダリングするアプリケーションをテストしたいと思います。レンダリングが完了したら、実際の幅と実際の高さを取得したいと思います。すべてが正常に動作します。アプリケーションをテストしようとしたときに、問題が最初に発生しました。テストプロジェクトからディスパッチャを呼び出すことができません。
以下はコードです。
this.Loaded += (s, e) =>
{
TextBlock textBlock1 = new TextBlock();
//// Text block value is assigned from data base field.
textBlock1.Text = strValueFromDataBaseField;
//// Setting the wrap behavior.
textBlock1.TextWrapping = TextWrapping.WrapWithOverflow;
//// Adding the text block to the layout canvas.
this.layoutCanvas.Children.Add(textBlock1);
this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
(Action)(() =>
{
//// After rendering the text block with the data base field value. Measuring the actual width and height.
this.TextBlockActualWidth = textBlock1.ActualWidth;
this.TextBlockActualHeight = textBlock1.ActualHeight;
//// Other calculations based on the actual widht and actual height.
}
));
};
NUnitを使い始めたばかりです。だから、私を助けてください。
ありがとう