flowdocumentscrollviewer で flowdocument のコンテンツを表示する際に問題が発生しています。int、string、および flowdocument を含むクラスを保持するジェネリック リストを作成します。
WPF リストボックスで、フロードキュメントをスクロールビューアにボタンと一緒に表示しようとしています。WPF ウィンドウ コンストラクターから呼び出される次の関数を使用して、リスト ボックスにデータを入力します。
private void populateListBox()
{
foreach(Element el in _notesList)
{
StackPanel sp = new StackPanel();
sp.Orientation = Orientation.Horizontal;
Button b = new Button();
b.Content = el._theID;
sp.Children.Add(b);
FlowDocumentScrollViewer fdsv = new FlowDocumentScrollViewer();
fdsv.MinWidth = 400;
fdsv.Document = el._theDoc;
sp.Children.Add(fdsv);
ListBoxItem lbi = new ListBoxItem();
lbi.Content = sp;
noteList.Items.Add(lbi);
}
}
しかし、コードは機能しません。エラーはありませんが、スクロールビューアはリストボックスで空白になっています。また、クラスを ObservableList に格納して Document プロパティにバインドしようとしましたが、どちらも機能しませんでした。
何が起こっているのですか?