0
DocumentFlowReaderを使用して、txtファイルのテキストを表示しています。すべてがうまくいっていますが、フルスクリーンのテキストを複数の列に分割した場合、どのように1つだけ表示するのですか?ここでC#WPFでDocumentFlowReaderを使用して単純なtxtファイルのテキストを1列に表示する方法
は私のコードです:
XAMLファイル:
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="_File">
<MenuItem x:Name="OpenFile" Header="_Open" Click="OpenFile_Click" />
<Separator />
<MenuItem Header="_Exit" />
</MenuItem>
</Menu>
<TextBlock x:Name="txtCurrentPage" DockPanel.Dock="Bottom" TextAlignment="Center" Background="LightYellow">
Current page:
</TextBlock>
<DockPanel DockPanel.Dock="Left">
<TextBlock DockPanel.Dock="Top">Your books</TextBlock>
<ListView DockPanel.Dock="Left" x:Name="listboxBooks" Grid.Row="1" BorderThickness="0" ItemsSource="{Binding}" PreviewMouseDoubleClick="listboxBooks_PreviewMouseDoubleClick">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="120" DisplayMemberBinding="{Binding name}" />
<GridViewColumn Header="Finished" Width="120" DisplayMemberBinding="{Binding readBook}" />
</GridView>
</ListView.View>
</ListView>
</DockPanel>
<TextBlock DockPanel.Dock="Right" Background="Bisque">
<Button x:Name="btnPreviousPage" Click="btnPreviousPage_Click" >Previous Page</Button>
<Button x:Name="btnNextPage" Click="btnNextPage_Click">Next Page</Button>
<Button x:Name="btnSavePage" Click="btnSavePage_Click" >Save Page</Button>
</TextBlock>
<FlowDocumentReader Name="FlowDocReader" Background="LightBlue">
</FlowDocumentReader>
</DockPanel>
これは私がファイルからテキストを読み取る方法です:
// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Set filter for file extension and default file extension
dlg.DefaultExt = ".txt";
dlg.Filter = "Text Files (*.txt)|*.txt";
string filename = dlg.FileName;
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add(System.IO.File.ReadAllText(filename));
FlowDocument document = new FlowDocument(paragraph);
FlowDocReader.Document = document;
このコードは、[OK]をやっている、それは読んでいますデータが表示されますが、ウィンドウがフルスクリーンの場合は、テキストが複数の列に表示されます。ウィンドウがフルスクリーンであっても、1つだけに表示したい。どうやってやるの?