teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

見直しキャンペーン中

2023/07/28 16:40

投稿

TN8001
TN8001

スコア10111

answer CHANGED
@@ -1,269 +1,269 @@
1
- 追記では収まらないので、別回答にさせていただきます。
2
-
3
- やっていることは前の回答と同じなのですが、より具体的かつシンプルになっています。
4
- そのためまったく汎用的ではありません。
5
-
6
- ```xaml
7
- <Window x:Class="Questions355107.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Questions355107" Width="{Binding Settings.Window.Width, Mode=TwoWay}"
8
- Height="{Binding Settings.Window.Height, Mode=TwoWay}" Left="{Binding Settings.Window.Left, Mode=TwoWay}" Top="{Binding Settings.Window.Top, Mode=TwoWay}">
9
- <Window.DataContext>
10
- <local:ViewModel />
11
- </Window.DataContext>
12
- <Window.Resources>
13
- <DataTemplate DataType="{x:Type local:ContentModel}">
14
- <Border x:Name="b" Background="{Binding Brush}" SizeChanged="Border_SizeChanged">
15
- <Grid>
16
- <TextBlock>
17
- <TextBlock.Text>
18
- <MultiBinding StringFormat="{}{0:f2}, {1:f2}">
19
- <Binding ElementName="b" Path="ActualWidth" />
20
- <Binding ElementName="b" Path="ActualHeight" />
21
- </MultiBinding>
22
- </TextBlock.Text>
23
- </TextBlock>
24
- <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Bold" Text="{Binding Text}" />
25
- </Grid>
26
- </Border>
27
- </DataTemplate>
28
-
29
- <DataTemplate x:Key="OnePane">
30
- <ContentControl Content="{Binding Contents[0]}" />
31
- </DataTemplate>
32
- <DataTemplate x:Key="TwoPane">
33
- <local:TwoPane />
34
- </DataTemplate>
35
- <DataTemplate x:Key="ThreePane">
36
- <local:ThreePane />
37
- </DataTemplate>
38
- <DataTemplate x:Key="FourPane">
39
- <local:FourPane />
40
- </DataTemplate>
41
-
42
- <Style TargetType="GridSplitter">
43
- <Setter Property="HorizontalAlignment" Value="Stretch" />
44
- </Style>
45
-
46
- <Style x:Key="PaneStyle" TargetType="{x:Type ContentControl}">
47
- <Style.Triggers>
48
- <DataTrigger Binding="{Binding SelPane}" Value="1">
49
- <Setter Property="ContentTemplate" Value="{StaticResource OnePane}" />
50
- </DataTrigger>
51
- <DataTrigger Binding="{Binding SelPane}" Value="2">
52
- <Setter Property="ContentTemplate" Value="{StaticResource TwoPane}" />
53
- </DataTrigger>
54
- <DataTrigger Binding="{Binding SelPane}" Value="3">
55
- <Setter Property="ContentTemplate" Value="{StaticResource ThreePane}" />
56
- </DataTrigger>
57
- <DataTrigger Binding="{Binding SelPane}" Value="4">
58
- <Setter Property="ContentTemplate" Value="{StaticResource FourPane}" />
59
- </DataTrigger>
60
- </Style.Triggers>
61
- </Style>
62
-
63
- <Style x:Key="RadioListBoxItem" TargetType="{x:Type ListBoxItem}">
64
- <Setter Property="Template">
65
- <Setter.Value>
66
- <ControlTemplate TargetType="{x:Type ListBoxItem}">
67
- <RadioButton MinWidth="30" Content="{TemplateBinding Content}" IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource {x:Type ToggleButton}}" />
68
- </ControlTemplate>
69
- </Setter.Value>
70
- </Setter>
71
- </Style>
72
- </Window.Resources>
73
- <DockPanel>
74
- <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
75
- <Button Command="{Binding Save}" Content="Save" />
76
- <Button Command="{Binding Load}" Content="Load" />
77
- <ListBox Padding="-1" BorderThickness="0" ItemContainerStyle="{StaticResource RadioListBoxItem}" ItemsSource="{Binding Panes}" SelectedItem="{Binding SelPane}">
78
- <ListBox.ItemsPanel>
79
- <ItemsPanelTemplate>
80
- <StackPanel Orientation="Horizontal" />
81
- </ItemsPanelTemplate>
82
- </ListBox.ItemsPanel>
83
- </ListBox>
84
- <Button Command="{Binding View}" Content="View" />
85
- </StackPanel>
86
- <ContentControl Content="{Binding}" Style="{StaticResource PaneStyle}" />
87
- </DockPanel>
88
- </Window>
89
- ```
90
-
91
- ```C#
92
- using CommunityToolkit.Mvvm.ComponentModel;
93
- using CommunityToolkit.Mvvm.Input;
94
- using System.Collections.ObjectModel;
95
- using System.Diagnostics;
96
- using System.Text.Json;
97
- using System.Text.Json.Serialization;
98
- using System.Windows;
99
- using System.Windows.Controls;
100
- using System.Windows.Media;
101
-
102
- namespace Questions355107
103
- {
104
- public class WindowModel : ObservableObject
105
- {
106
- public double Top { get => top; set => SetProperty(ref top, value); }
107
- private double top = double.NaN;
108
- public double Left { get => left; set => SetProperty(ref left, value); }
109
- private double left = double.NaN;
110
- public double Width { get => width; set => SetProperty(ref width, value); }
111
- private double width = 800;
112
- public double Height { get => height; set => SetProperty(ref height, value); }
113
- private double height = 450;
114
- }
115
-
116
- // 分割割合保存復元用 GridSplitter1本に対し文字列2つ
117
- // 大元(Settings)から変わるので、SetPropertyしなくてよかった模様
118
- // ついでに配列化してすっきり
119
- public class SplitterModel
120
- {
121
- public string[] TwoPane { get; set; } = { "1*", "1*", };
122
- public string[] ThreePane { get; set; } = { "3*", "2*", "1*", "1*" };
123
- public string[] FourPane { get; set; } = { "1*", "1*", "1*", "1*", };
124
- }
125
-
126
- public class SettingsModel
127
- {
128
- public WindowModel Window { get; set; } = new();
129
- public SplitterModel Splitter { get; set; } = new();
130
- }
131
-
132
- public class ContentModel
133
- {
134
- public string Text { get; set; }
135
-
136
- // 実際に欲しい数値はここ
137
- // Viewから値が入るのみ コードから値を入れてもViewには反映しないので注意
138
- public double Width { get; set; }
139
- public double Height { get; set; }
140
- public Brush Brush { get; set; }
141
- }
142
-
143
- public class ViewModel : ObservableObject
144
- {
145
- public SettingsModel Settings { get => settings; set => SetProperty(ref settings, value); }
146
- private SettingsModel settings;
147
-
148
- public int[] Panes { get; } = { 1, 2, 3, 4, };
149
- public int SelPane { get => selPane; set => SetProperty(ref selPane, value); }
150
- private int selPane = 3;
151
- public ObservableCollection<ContentModel> Contents { get; }
152
-
153
- public RelayCommand Save { get; }
154
- public RelayCommand Load { get; }
155
- public RelayCommand View { get; }
156
-
157
- private string settingsJson;
158
- private readonly JsonSerializerOptions options = new()
159
- {
160
- NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals,
161
- WriteIndented = true,
162
- };
163
-
164
- public ViewModel()
165
- {
166
- Settings = new();
167
- Contents = new()
168
- {
169
- new() { Text = "①", Brush = Brushes.LightCoral, },
170
- new() { Text = "②", Brush = Brushes.LightGreen, },
171
- new() { Text = "③", Brush = Brushes.SkyBlue, },
172
- new() { Text = "④", Brush = Brushes.Pink, },
173
- };
174
- Save = new(() =>
175
- {
176
- settingsJson = JsonSerializer.Serialize(Settings, options);
177
- Debug.WriteLine(settingsJson);
178
- });
179
- Load = new(() =>
180
- {
181
- Settings = null;
182
- Settings = JsonSerializer.Deserialize<SettingsModel>(settingsJson, options);
183
- });
184
- View = new(() =>
185
- {
186
- foreach (var c in Contents)
187
- Debug.WriteLine($"{c.Text}: {c.Width:f2}, {c.Height:f2}");
188
- });
189
- Save.Execute(null);
190
- }
191
- }
192
-
193
- public partial class MainWindow : Window
194
- {
195
- public MainWindow() => InitializeComponent();
196
- private void Border_SizeChanged(object sender, SizeChangedEventArgs e)
197
- {
198
- if (sender is Border b && b.DataContext is ContentModel c)
199
- {
200
- c.Width = b.ActualWidth;
201
- c.Height = b.ActualHeight;
202
- }
203
- }
204
- }
205
- }
206
- ```
207
-
208
- ```xaml
209
- <UserControl x:Class="Questions355107.TwoPane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
210
- <Grid>
211
- <Grid.ColumnDefinitions>
212
- <ColumnDefinition Width="{Binding Settings.Splitter.TwoPane[0], Mode=TwoWay}" />
213
- <ColumnDefinition Width="5" />
214
- <ColumnDefinition Width="{Binding Settings.Splitter.TwoPane[1], Mode=TwoWay}" />
215
- </Grid.ColumnDefinitions>
216
- <ContentControl Content="{Binding Contents[0]}" />
217
- <GridSplitter Grid.Column="1" />
218
- <ContentControl Grid.Column="2" Content="{Binding Contents[1]}" />
219
- </Grid>
220
- </UserControl>
221
- ```
222
-
223
- ```xaml
224
- <UserControl x:Class="Questions355107.ThreePane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
225
- <Grid>
226
- <Grid.ColumnDefinitions>
227
- <ColumnDefinition Width="{Binding Settings.Splitter.ThreePane[0], Mode=TwoWay}" />
228
- <ColumnDefinition Width="5" />
229
- <ColumnDefinition Width="{Binding Settings.Splitter.ThreePane[1], Mode=TwoWay}" />
230
- </Grid.ColumnDefinitions>
231
- <ContentControl Content="{Binding Contents[0]}" />
232
- <GridSplitter Grid.Column="1" />
233
- <Grid Grid.Column="2">
234
- <Grid.RowDefinitions>
235
- <RowDefinition Height="{Binding Settings.Splitter.ThreePane[2], Mode=TwoWay}" />
236
- <RowDefinition Height="5" />
237
- <RowDefinition Height="{Binding Settings.Splitter.ThreePane[3], Mode=TwoWay}" />
238
- </Grid.RowDefinitions>
239
- <ContentControl Content="{Binding Contents[1]}" />
240
- <GridSplitter Grid.Row="1" />
241
- <ContentControl Grid.Row="2" Content="{Binding Contents[2]}" />
242
- </Grid>
243
- </Grid>
244
- </UserControl>
245
- ```
246
-
247
- ```xaml
248
- <UserControl x:Class="Questions355107.FourPane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
249
- <Grid>
250
- <Grid.ColumnDefinitions>
251
- <ColumnDefinition Width="{Binding Settings.Splitter.FourPane[0], Mode=TwoWay}" />
252
- <ColumnDefinition Width="5" />
253
- <ColumnDefinition Width="{Binding Settings.Splitter.FourPane[1], Mode=TwoWay}" />
254
- </Grid.ColumnDefinitions>
255
- <Grid.RowDefinitions>
256
- <RowDefinition Height="{Binding Settings.Splitter.FourPane[2], Mode=TwoWay}" />
257
- <RowDefinition Height="5" />
258
- <RowDefinition Height="{Binding Settings.Splitter.FourPane[3], Mode=TwoWay}" />
259
- </Grid.RowDefinitions>
260
- <ContentControl Content="{Binding Contents[0]}" />
261
- <ContentControl Grid.Row="2" Content="{Binding Contents[1]}" />
262
- <ContentControl Grid.Column="2" Content="{Binding Contents[2]}" />
263
- <ContentControl Grid.Row="2" Grid.Column="2" Content="{Binding Contents[3]}" />
264
- <GridSplitter Grid.RowSpan="3" Grid.Column="1" />
265
- <GridSplitter Grid.Row="1" Grid.ColumnSpan="3" />
266
- </Grid>
267
- </UserControl>
268
- ```
1
+ 追記では収まらないので、別回答にさせていただきます。
2
+
3
+ やっていることは前の回答と同じなのですが、より具体的かつシンプルになっています。
4
+ そのためまったく汎用的ではありません。
5
+
6
+ ```xml:MainWindow.xaml
7
+ <Window x:Class="Questions355107.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Questions355107" Width="{Binding Settings.Window.Width, Mode=TwoWay}"
8
+ Height="{Binding Settings.Window.Height, Mode=TwoWay}" Left="{Binding Settings.Window.Left, Mode=TwoWay}" Top="{Binding Settings.Window.Top, Mode=TwoWay}">
9
+ <Window.DataContext>
10
+ <local:ViewModel />
11
+ </Window.DataContext>
12
+ <Window.Resources>
13
+ <DataTemplate DataType="{x:Type local:ContentModel}">
14
+ <Border x:Name="b" Background="{Binding Brush}" SizeChanged="Border_SizeChanged">
15
+ <Grid>
16
+ <TextBlock>
17
+ <TextBlock.Text>
18
+ <MultiBinding StringFormat="{}{0:f2}, {1:f2}">
19
+ <Binding ElementName="b" Path="ActualWidth" />
20
+ <Binding ElementName="b" Path="ActualHeight" />
21
+ </MultiBinding>
22
+ </TextBlock.Text>
23
+ </TextBlock>
24
+ <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Bold" Text="{Binding Text}" />
25
+ </Grid>
26
+ </Border>
27
+ </DataTemplate>
28
+
29
+ <DataTemplate x:Key="OnePane">
30
+ <ContentControl Content="{Binding Contents[0]}" />
31
+ </DataTemplate>
32
+ <DataTemplate x:Key="TwoPane">
33
+ <local:TwoPane />
34
+ </DataTemplate>
35
+ <DataTemplate x:Key="ThreePane">
36
+ <local:ThreePane />
37
+ </DataTemplate>
38
+ <DataTemplate x:Key="FourPane">
39
+ <local:FourPane />
40
+ </DataTemplate>
41
+
42
+ <Style TargetType="GridSplitter">
43
+ <Setter Property="HorizontalAlignment" Value="Stretch" />
44
+ </Style>
45
+
46
+ <Style x:Key="PaneStyle" TargetType="{x:Type ContentControl}">
47
+ <Style.Triggers>
48
+ <DataTrigger Binding="{Binding SelPane}" Value="1">
49
+ <Setter Property="ContentTemplate" Value="{StaticResource OnePane}" />
50
+ </DataTrigger>
51
+ <DataTrigger Binding="{Binding SelPane}" Value="2">
52
+ <Setter Property="ContentTemplate" Value="{StaticResource TwoPane}" />
53
+ </DataTrigger>
54
+ <DataTrigger Binding="{Binding SelPane}" Value="3">
55
+ <Setter Property="ContentTemplate" Value="{StaticResource ThreePane}" />
56
+ </DataTrigger>
57
+ <DataTrigger Binding="{Binding SelPane}" Value="4">
58
+ <Setter Property="ContentTemplate" Value="{StaticResource FourPane}" />
59
+ </DataTrigger>
60
+ </Style.Triggers>
61
+ </Style>
62
+
63
+ <Style x:Key="RadioListBoxItem" TargetType="{x:Type ListBoxItem}">
64
+ <Setter Property="Template">
65
+ <Setter.Value>
66
+ <ControlTemplate TargetType="{x:Type ListBoxItem}">
67
+ <RadioButton MinWidth="30" Content="{TemplateBinding Content}" IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource {x:Type ToggleButton}}" />
68
+ </ControlTemplate>
69
+ </Setter.Value>
70
+ </Setter>
71
+ </Style>
72
+ </Window.Resources>
73
+ <DockPanel>
74
+ <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
75
+ <Button Command="{Binding Save}" Content="Save" />
76
+ <Button Command="{Binding Load}" Content="Load" />
77
+ <ListBox Padding="-1" BorderThickness="0" ItemContainerStyle="{StaticResource RadioListBoxItem}" ItemsSource="{Binding Panes}" SelectedItem="{Binding SelPane}">
78
+ <ListBox.ItemsPanel>
79
+ <ItemsPanelTemplate>
80
+ <StackPanel Orientation="Horizontal" />
81
+ </ItemsPanelTemplate>
82
+ </ListBox.ItemsPanel>
83
+ </ListBox>
84
+ <Button Command="{Binding View}" Content="View" />
85
+ </StackPanel>
86
+ <ContentControl Content="{Binding}" Style="{StaticResource PaneStyle}" />
87
+ </DockPanel>
88
+ </Window>
89
+ ```
90
+
91
+ ```cs
92
+ using CommunityToolkit.Mvvm.ComponentModel;
93
+ using CommunityToolkit.Mvvm.Input;
94
+ using System.Collections.ObjectModel;
95
+ using System.Diagnostics;
96
+ using System.Text.Json;
97
+ using System.Text.Json.Serialization;
98
+ using System.Windows;
99
+ using System.Windows.Controls;
100
+ using System.Windows.Media;
101
+
102
+ namespace Questions355107
103
+ {
104
+ public class WindowModel : ObservableObject
105
+ {
106
+ public double Top { get => top; set => SetProperty(ref top, value); }
107
+ private double top = double.NaN;
108
+ public double Left { get => left; set => SetProperty(ref left, value); }
109
+ private double left = double.NaN;
110
+ public double Width { get => width; set => SetProperty(ref width, value); }
111
+ private double width = 800;
112
+ public double Height { get => height; set => SetProperty(ref height, value); }
113
+ private double height = 450;
114
+ }
115
+
116
+ // 分割割合保存復元用 GridSplitter1本に対し文字列2つ
117
+ // 大元(Settings)から変わるので、SetPropertyしなくてよかった模様
118
+ // ついでに配列化してすっきり
119
+ public class SplitterModel
120
+ {
121
+ public string[] TwoPane { get; set; } = { "1*", "1*", };
122
+ public string[] ThreePane { get; set; } = { "3*", "2*", "1*", "1*" };
123
+ public string[] FourPane { get; set; } = { "1*", "1*", "1*", "1*", };
124
+ }
125
+
126
+ public class SettingsModel
127
+ {
128
+ public WindowModel Window { get; set; } = new();
129
+ public SplitterModel Splitter { get; set; } = new();
130
+ }
131
+
132
+ public class ContentModel
133
+ {
134
+ public string Text { get; set; }
135
+
136
+ // 実際に欲しい数値はここ
137
+ // Viewから値が入るのみ コードから値を入れてもViewには反映しないので注意
138
+ public double Width { get; set; }
139
+ public double Height { get; set; }
140
+ public Brush Brush { get; set; }
141
+ }
142
+
143
+ public class ViewModel : ObservableObject
144
+ {
145
+ public SettingsModel Settings { get => settings; set => SetProperty(ref settings, value); }
146
+ private SettingsModel settings;
147
+
148
+ public int[] Panes { get; } = { 1, 2, 3, 4, };
149
+ public int SelPane { get => selPane; set => SetProperty(ref selPane, value); }
150
+ private int selPane = 3;
151
+ public ObservableCollection<ContentModel> Contents { get; }
152
+
153
+ public RelayCommand Save { get; }
154
+ public RelayCommand Load { get; }
155
+ public RelayCommand View { get; }
156
+
157
+ private string settingsJson;
158
+ private readonly JsonSerializerOptions options = new()
159
+ {
160
+ NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals,
161
+ WriteIndented = true,
162
+ };
163
+
164
+ public ViewModel()
165
+ {
166
+ Settings = new();
167
+ Contents = new()
168
+ {
169
+ new() { Text = "①", Brush = Brushes.LightCoral, },
170
+ new() { Text = "②", Brush = Brushes.LightGreen, },
171
+ new() { Text = "③", Brush = Brushes.SkyBlue, },
172
+ new() { Text = "④", Brush = Brushes.Pink, },
173
+ };
174
+ Save = new(() =>
175
+ {
176
+ settingsJson = JsonSerializer.Serialize(Settings, options);
177
+ Debug.WriteLine(settingsJson);
178
+ });
179
+ Load = new(() =>
180
+ {
181
+ Settings = null;
182
+ Settings = JsonSerializer.Deserialize<SettingsModel>(settingsJson, options);
183
+ });
184
+ View = new(() =>
185
+ {
186
+ foreach (var c in Contents)
187
+ Debug.WriteLine($"{c.Text}: {c.Width:f2}, {c.Height:f2}");
188
+ });
189
+ Save.Execute(null);
190
+ }
191
+ }
192
+
193
+ public partial class MainWindow : Window
194
+ {
195
+ public MainWindow() => InitializeComponent();
196
+ private void Border_SizeChanged(object sender, SizeChangedEventArgs e)
197
+ {
198
+ if (sender is Border b && b.DataContext is ContentModel c)
199
+ {
200
+ c.Width = b.ActualWidth;
201
+ c.Height = b.ActualHeight;
202
+ }
203
+ }
204
+ }
205
+ }
206
+ ```
207
+
208
+ ```xml:TwoPane.xaml
209
+ <UserControl x:Class="Questions355107.TwoPane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
210
+ <Grid>
211
+ <Grid.ColumnDefinitions>
212
+ <ColumnDefinition Width="{Binding Settings.Splitter.TwoPane[0], Mode=TwoWay}" />
213
+ <ColumnDefinition Width="5" />
214
+ <ColumnDefinition Width="{Binding Settings.Splitter.TwoPane[1], Mode=TwoWay}" />
215
+ </Grid.ColumnDefinitions>
216
+ <ContentControl Content="{Binding Contents[0]}" />
217
+ <GridSplitter Grid.Column="1" />
218
+ <ContentControl Grid.Column="2" Content="{Binding Contents[1]}" />
219
+ </Grid>
220
+ </UserControl>
221
+ ```
222
+
223
+ ```xml:ThreePane.xaml
224
+ <UserControl x:Class="Questions355107.ThreePane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
225
+ <Grid>
226
+ <Grid.ColumnDefinitions>
227
+ <ColumnDefinition Width="{Binding Settings.Splitter.ThreePane[0], Mode=TwoWay}" />
228
+ <ColumnDefinition Width="5" />
229
+ <ColumnDefinition Width="{Binding Settings.Splitter.ThreePane[1], Mode=TwoWay}" />
230
+ </Grid.ColumnDefinitions>
231
+ <ContentControl Content="{Binding Contents[0]}" />
232
+ <GridSplitter Grid.Column="1" />
233
+ <Grid Grid.Column="2">
234
+ <Grid.RowDefinitions>
235
+ <RowDefinition Height="{Binding Settings.Splitter.ThreePane[2], Mode=TwoWay}" />
236
+ <RowDefinition Height="5" />
237
+ <RowDefinition Height="{Binding Settings.Splitter.ThreePane[3], Mode=TwoWay}" />
238
+ </Grid.RowDefinitions>
239
+ <ContentControl Content="{Binding Contents[1]}" />
240
+ <GridSplitter Grid.Row="1" />
241
+ <ContentControl Grid.Row="2" Content="{Binding Contents[2]}" />
242
+ </Grid>
243
+ </Grid>
244
+ </UserControl>
245
+ ```
246
+
247
+ ```xml:FourPane.xaml
248
+ <UserControl x:Class="Questions355107.FourPane" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
249
+ <Grid>
250
+ <Grid.ColumnDefinitions>
251
+ <ColumnDefinition Width="{Binding Settings.Splitter.FourPane[0], Mode=TwoWay}" />
252
+ <ColumnDefinition Width="5" />
253
+ <ColumnDefinition Width="{Binding Settings.Splitter.FourPane[1], Mode=TwoWay}" />
254
+ </Grid.ColumnDefinitions>
255
+ <Grid.RowDefinitions>
256
+ <RowDefinition Height="{Binding Settings.Splitter.FourPane[2], Mode=TwoWay}" />
257
+ <RowDefinition Height="5" />
258
+ <RowDefinition Height="{Binding Settings.Splitter.FourPane[3], Mode=TwoWay}" />
259
+ </Grid.RowDefinitions>
260
+ <ContentControl Content="{Binding Contents[0]}" />
261
+ <ContentControl Grid.Row="2" Content="{Binding Contents[1]}" />
262
+ <ContentControl Grid.Column="2" Content="{Binding Contents[2]}" />
263
+ <ContentControl Grid.Row="2" Grid.Column="2" Content="{Binding Contents[3]}" />
264
+ <GridSplitter Grid.RowSpan="3" Grid.Column="1" />
265
+ <GridSplitter Grid.Row="1" Grid.ColumnSpan="3" />
266
+ </Grid>
267
+ </UserControl>
268
+ ```
269
269
  ![アプリ画像](9d7dc049e87998b40fb61771dda21579.png)