回答編集履歴
2
見直しキャンペーン中
answer
CHANGED
@@ -1,77 +1,77 @@
|
|
1
|
-
どこで改ページしたいのかが伝わりませんが、次ページに送りたいブロック要素の`BreakPageBefore`を`true`にすればいいんじゃないでしょうか。
|
2
|
-
|
3
|
-
[Block.BreakPageBefore プロパティ (System.Windows.Documents) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.documents.block.breakpagebefore#System_Windows_Documents_Block_BreakPageBefore)
|
4
|
-
|
5
|
-
```
|
6
|
-
<FlowDocument>
|
7
|
-
<Paragraph Background="Beige" FontFamily="Georgia">
|
8
|
-
<TextBlock Height="70" Text="{Binding Shindan}" />
|
9
|
-
</Paragraph>
|
10
|
-
|
11
|
-
<Paragraph
|
12
|
-
Background="Bisque"
|
13
|
-
BreakPageBefore="True"
|
14
|
-
FontFamily="Georgia">
|
15
|
-
<TextBlock Height="120" Text="{Binding Shoken}" />
|
16
|
-
</Paragraph>
|
17
|
-
</FlowDocument>
|
18
|
-
```
|
19
|
-
|
20
|
-
---
|
21
|
-
|
22
|
-
追記 コードビハインド
|
23
|
-
```
|
24
|
-
using System.Collections.Generic;
|
25
|
-
using System.Windows;
|
26
|
-
using System.Windows.Documents;
|
27
|
-
|
28
|
-
namespace Questions320442
|
29
|
-
{
|
30
|
-
public partial class MainWindow : Window
|
31
|
-
{
|
32
|
-
private Model Model;
|
33
|
-
|
34
|
-
public MainWindow()
|
35
|
-
{
|
36
|
-
InitializeComponent();
|
37
|
-
|
38
|
-
Model = new Model
|
39
|
-
{
|
40
|
-
_report = new List<Report>
|
41
|
-
{
|
42
|
-
new Report { データ1 = "page1", データ2 = "hogehoge", },
|
43
|
-
new Report { データ1 = "page2", データ2 = "fugafuga", },
|
44
|
-
// もちろん内容が長ければ途中で改ページが入るのでずれます
|
45
|
-
new Report { データ1 = "page3", データ2 = "piyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\n", },
|
46
|
-
}
|
47
|
-
};
|
48
|
-
|
49
|
-
var flowDocument = new FlowDocument();
|
50
|
-
foreach (var txt in Model._report)
|
51
|
-
{
|
52
|
-
// Paragraphもブロック要素
|
53
|
-
var paragraph = new Paragraph { FontSize = 16, BreakPageBefore = true, };
|
54
|
-
paragraph.Inlines.Add(txt.データ1);
|
55
|
-
|
56
|
-
paragraph.Inlines.Add(new LineBreak());
|
57
|
-
|
58
|
-
paragraph.Inlines.Add(txt.データ2);
|
59
|
-
flowDocument.Blocks.Add(paragraph);
|
60
|
-
}
|
61
|
-
|
62
|
-
flowDoc.Document = flowDocument;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
class Model
|
67
|
-
{
|
68
|
-
public IEnumerable<Report> _report;
|
69
|
-
}
|
70
|
-
|
71
|
-
class Report
|
72
|
-
{
|
73
|
-
public string データ1;
|
74
|
-
public string データ2;
|
75
|
-
}
|
76
|
-
}
|
1
|
+
どこで改ページしたいのかが伝わりませんが、次ページに送りたいブロック要素の`BreakPageBefore`を`true`にすればいいんじゃないでしょうか。
|
2
|
+
|
3
|
+
[Block.BreakPageBefore プロパティ (System.Windows.Documents) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.documents.block.breakpagebefore#System_Windows_Documents_Block_BreakPageBefore)
|
4
|
+
|
5
|
+
```xml
|
6
|
+
<FlowDocument>
|
7
|
+
<Paragraph Background="Beige" FontFamily="Georgia">
|
8
|
+
<TextBlock Height="70" Text="{Binding Shindan}" />
|
9
|
+
</Paragraph>
|
10
|
+
|
11
|
+
<Paragraph
|
12
|
+
Background="Bisque"
|
13
|
+
BreakPageBefore="True"
|
14
|
+
FontFamily="Georgia">
|
15
|
+
<TextBlock Height="120" Text="{Binding Shoken}" />
|
16
|
+
</Paragraph>
|
17
|
+
</FlowDocument>
|
18
|
+
```
|
19
|
+
|
20
|
+
---
|
21
|
+
|
22
|
+
追記 コードビハインド
|
23
|
+
```cs
|
24
|
+
using System.Collections.Generic;
|
25
|
+
using System.Windows;
|
26
|
+
using System.Windows.Documents;
|
27
|
+
|
28
|
+
namespace Questions320442
|
29
|
+
{
|
30
|
+
public partial class MainWindow : Window
|
31
|
+
{
|
32
|
+
private Model Model;
|
33
|
+
|
34
|
+
public MainWindow()
|
35
|
+
{
|
36
|
+
InitializeComponent();
|
37
|
+
|
38
|
+
Model = new Model
|
39
|
+
{
|
40
|
+
_report = new List<Report>
|
41
|
+
{
|
42
|
+
new Report { データ1 = "page1", データ2 = "hogehoge", },
|
43
|
+
new Report { データ1 = "page2", データ2 = "fugafuga", },
|
44
|
+
// もちろん内容が長ければ途中で改ページが入るのでずれます
|
45
|
+
new Report { データ1 = "page3", データ2 = "piyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\n", },
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
var flowDocument = new FlowDocument();
|
50
|
+
foreach (var txt in Model._report)
|
51
|
+
{
|
52
|
+
// Paragraphもブロック要素
|
53
|
+
var paragraph = new Paragraph { FontSize = 16, BreakPageBefore = true, };
|
54
|
+
paragraph.Inlines.Add(txt.データ1);
|
55
|
+
|
56
|
+
paragraph.Inlines.Add(new LineBreak());
|
57
|
+
|
58
|
+
paragraph.Inlines.Add(txt.データ2);
|
59
|
+
flowDocument.Blocks.Add(paragraph);
|
60
|
+
}
|
61
|
+
|
62
|
+
flowDoc.Document = flowDocument;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
class Model
|
67
|
+
{
|
68
|
+
public IEnumerable<Report> _report;
|
69
|
+
}
|
70
|
+
|
71
|
+
class Report
|
72
|
+
{
|
73
|
+
public string データ1;
|
74
|
+
public string データ2;
|
75
|
+
}
|
76
|
+
}
|
77
77
|
```
|
1
追記 コードビハインド
answer
CHANGED
@@ -15,4 +15,63 @@
|
|
15
15
|
<TextBlock Height="120" Text="{Binding Shoken}" />
|
16
16
|
</Paragraph>
|
17
17
|
</FlowDocument>
|
18
|
+
```
|
19
|
+
|
20
|
+
---
|
21
|
+
|
22
|
+
追記 コードビハインド
|
23
|
+
```C#
|
24
|
+
using System.Collections.Generic;
|
25
|
+
using System.Windows;
|
26
|
+
using System.Windows.Documents;
|
27
|
+
|
28
|
+
namespace Questions320442
|
29
|
+
{
|
30
|
+
public partial class MainWindow : Window
|
31
|
+
{
|
32
|
+
private Model Model;
|
33
|
+
|
34
|
+
public MainWindow()
|
35
|
+
{
|
36
|
+
InitializeComponent();
|
37
|
+
|
38
|
+
Model = new Model
|
39
|
+
{
|
40
|
+
_report = new List<Report>
|
41
|
+
{
|
42
|
+
new Report { データ1 = "page1", データ2 = "hogehoge", },
|
43
|
+
new Report { データ1 = "page2", データ2 = "fugafuga", },
|
44
|
+
// もちろん内容が長ければ途中で改ページが入るのでずれます
|
45
|
+
new Report { データ1 = "page3", データ2 = "piyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\npiyo\n", },
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
var flowDocument = new FlowDocument();
|
50
|
+
foreach (var txt in Model._report)
|
51
|
+
{
|
52
|
+
// Paragraphもブロック要素
|
53
|
+
var paragraph = new Paragraph { FontSize = 16, BreakPageBefore = true, };
|
54
|
+
paragraph.Inlines.Add(txt.データ1);
|
55
|
+
|
56
|
+
paragraph.Inlines.Add(new LineBreak());
|
57
|
+
|
58
|
+
paragraph.Inlines.Add(txt.データ2);
|
59
|
+
flowDocument.Blocks.Add(paragraph);
|
60
|
+
}
|
61
|
+
|
62
|
+
flowDoc.Document = flowDocument;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
class Model
|
67
|
+
{
|
68
|
+
public IEnumerable<Report> _report;
|
69
|
+
}
|
70
|
+
|
71
|
+
class Report
|
72
|
+
{
|
73
|
+
public string データ1;
|
74
|
+
public string データ2;
|
75
|
+
}
|
76
|
+
}
|
18
77
|
```
|