├── .editorconfig
├── .github
└── dependabot.yml
├── .gitignore
├── Gu.Wpf.AutoRowGrid.Demo
├── .editorconfig
├── App.xaml
├── App.xaml.cs
├── AssemblyAttributes.cs
├── AutoIncrementColumnsView.xaml
├── AutoIncrementColumnsView.xaml.cs
├── ColumnDefinitionsView.xaml
├── ColumnDefinitionsView.xaml.cs
├── ColumnSpanView.xaml
├── ColumnSpanView.xaml.cs
├── ExplicitColumnsView.xaml
├── ExplicitColumnsView.xaml.cs
├── Gu.Wpf.AutoRowGrid.Demo.csproj
├── Gu.Wpf.AutoRowGrid.Demo.csproj.DotSettings
├── LastRowFillView.xaml
├── LastRowFillView.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── NestedRowsView.xaml
├── NestedRowsView.xaml.cs
├── RowHeightView.xaml
├── RowHeightView.xaml.cs
├── SandBoxView.xaml
├── SandBoxView.xaml.cs
├── UiTestWindows
│ ├── AutoRowsAndColumnsExplicitHeightWindow.xaml
│ ├── AutoRowsAndColumnsExplicitHeightWindow.xaml.cs
│ ├── AutoRowsAndColumnsExplicitStarHeightWindow.xaml
│ ├── AutoRowsAndColumnsExplicitStarHeightWindow.xaml.cs
│ ├── AutoRowsAndColumnsWindow.xaml
│ ├── AutoRowsAndColumnsWindow.xaml.cs
│ ├── AutoRowsLastRowFillWindow.xaml
│ ├── AutoRowsLastRowFillWindow.xaml.cs
│ ├── ExplicitRowsAndColumnsLastRowWindow.xaml
│ ├── ExplicitRowsAndColumnsLastRowWindow.xaml.cs
│ ├── ExplicitRowsAndColumnsWindow.xaml
│ ├── ExplicitRowsAndColumnsWindow.xaml.cs
│ ├── NestedRowsExplicitHeightWindow.xaml
│ ├── NestedRowsExplicitHeightWindow.xaml.cs
│ ├── NestedRowsWindow.xaml
│ ├── NestedRowsWindow.xaml.cs
│ ├── TestElement.cs
│ ├── TextBoxView.cs
│ └── VisualTreeExt.cs
└── ViewModel.cs
├── Gu.Wpf.AutoRowGrid.UiTests
├── .editorconfig
├── AssemblyAttributes.cs
├── AutoRowsAndColumnsExplicitHeightTests.cs
├── AutoRowsAndColumnsExplicitStarHeightTests.cs
├── AutoRowsAndColumnsWindowTests.cs
├── AutoRowsLastRowFillTests.cs
├── ExplicitRowsAndColumnsLastRowFillTests.cs
├── ExplicitRowsAndColumnsTests.cs
├── Gu.Wpf.AutoRowGrid.UiTests.csproj
├── Gu.Wpf.AutoRowGrid.UiTests.csproj.DotSettings
├── Helpers
│ └── WindowExt.cs
├── NestedRowsExplicitHeightTests.cs
└── NestedRowsTests.cs
├── Gu.Wpf.AutoRowGrid.sln
├── Gu.Wpf.AutoRowGrid.sln.DotSettings
├── Gu.Wpf.AutoRowGrid
├── .editorconfig
├── AssemblyAttributes.cs
├── AutoIncrement.cs
├── AutoIncrementation.cs
├── ColumnDefinitions
│ ├── ColumnDefinitions.cs
│ ├── ColumnDefinitionsConverter.cs
│ └── GridLengthsParser.cs
├── GridExtension.cs
├── Gu.Wpf.AutoRowGrid.csproj
├── Gu.Wpf.AutoRowGrid.csproj.DotSettings
├── Gu.Wpf.AutoRowGrid.snk
├── IRow.cs
├── PublicAPI.Shipped.txt
├── PublicAPI.Unshipped.txt
├── Row.cs
├── Rows.cs
└── stylecop.json
├── LICENSE
├── README.md
├── RELEASE_NOTES.md
├── appveyor.yml
└── azure-pipelines.yml
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.xaml]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = crlf
7 | trim_trailing_spaces = true
8 | insert_final_newline = true
9 | charset = utf-8
10 |
11 | [*.csproj]
12 | indent_style = space
13 | indent_size = 2
14 | end_of_line = crlf
15 | trim_trailing_spaces = true
16 | insert_final_newline = true
17 | charset = utf-8
18 |
19 | [*.cs]
20 | indent_style = space
21 | indent_size = 4
22 | end_of_line = crlf
23 | trim_trailing_spaces = true
24 | insert_final_newline = true
25 | charset = utf-8
26 |
27 | # Sort using and Import directives with System.* appearing first
28 | dotnet_sort_system_directives_first = true
29 |
30 | # Always use "this." and "Me." when applicable; let StyleCop Analyzers provide the warning and fix
31 | dotnet_style_qualification_for_field = true:suggestion
32 | dotnet_style_qualification_for_property = true:suggestion
33 | dotnet_style_qualification_for_method = true:suggestion
34 | dotnet_style_qualification_for_event = true:suggestion
35 |
36 | # Use language keywords where applicable; let StyleCop Analyzers provide the warning and fix
37 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
38 | dotnet_style_predefined_type_for_member_access = true:suggestion
39 |
40 | # Suggest more modern language features when available
41 | dotnet_style_object_initializer = true:suggestion
42 | dotnet_style_collection_initializer = true:suggestion
43 | dotnet_style_coalesce_expression = true:suggestion
44 | dotnet_style_null_propagation = true:suggestion
45 | dotnet_style_explicit_tuple_names = true:suggestion
46 |
47 | # New line preferences
48 | csharp_new_line_before_open_brace = all
49 | csharp_new_line_before_else = true
50 | csharp_new_line_before_catch = true
51 | csharp_new_line_before_finally = true
52 | csharp_new_line_before_members_in_object_initializers = true
53 | csharp_new_line_before_members_in_anonymous_types = true
54 | csharp_new_line_within_query_expression_clauses = true
55 |
56 | # Indentation preferences
57 | csharp_indent_block_contents = true
58 | csharp_indent_braces = false
59 | csharp_indent_case_contents = true
60 | csharp_indent_switch_labels = true
61 | csharp_indent_labels = flush_left
62 |
63 | # Space preferences
64 | csharp_space_after_cast = false
65 | csharp_space_after_colon_in_inheritance_clause = true
66 | csharp_space_after_comma = true
67 | csharp_space_after_dot = false
68 | csharp_space_after_keywords_in_control_flow_statements = true
69 | csharp_space_after_semicolon_in_for_statement = true
70 | csharp_space_around_binary_operators = before_and_after
71 | csharp_space_around_declaration_statements = do_not_ignore
72 | csharp_space_before_colon_in_inheritance_clause = true
73 | csharp_space_before_comma = false
74 | csharp_space_before_dot = false
75 | csharp_space_before_open_square_brackets = false
76 | csharp_space_before_semicolon_in_for_statement = false
77 | csharp_space_between_empty_square_brackets = false
78 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
79 | csharp_space_between_method_call_name_and_opening_parenthesis = false
80 | csharp_space_between_method_call_parameter_list_parentheses = false
81 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
82 | csharp_space_between_method_declaration_name_and_open_parenthesis = false
83 | csharp_space_between_method_declaration_parameter_list_parentheses = false
84 | csharp_space_between_parentheses = false
85 | csharp_space_between_square_brackets = false
86 |
87 | # Prefer "var" only where type is obvious; disable diagnostics since no firm policy is in place yet
88 | csharp_style_var_for_built_in_types = false:none
89 | csharp_style_var_when_type_is_apparent = true:none
90 | csharp_style_var_elsewhere = false:none
91 |
92 | # Prefer method-like constructs to have a block body
93 | csharp_style_expression_bodied_methods = false:none
94 | csharp_style_expression_bodied_constructors = false:none
95 | csharp_style_expression_bodied_operators = false:none
96 |
97 | # Prefer property-like constructs to have an expression-body
98 | csharp_style_expression_bodied_properties = true:none
99 | csharp_style_expression_bodied_indexers = true:none
100 | csharp_style_expression_bodied_accessors = true:none
101 |
102 | # Suggest more modern language features when available
103 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
104 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
105 | csharp_style_inlined_variable_declaration = true:none
106 | csharp_style_throw_expression = true:none
107 | csharp_style_conditional_delegate_call = true:suggestion
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: nuget
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ###### -- File Created With Git Source Control Provider 2015 -- ######
2 | ###### -- From https://github.com/github/gitignore -- ######
3 | ###### -- Warning Regenerating this file will erase all your custom ignores, unless you add them below the Custom Ignore section at the bottom -- ######
4 | ## Ignore Visual Studio temporary files, build results, and
5 | ## files generated by popular Visual Studio add-ons.
6 |
7 | # User-specific files
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # MSTest test Results
34 | [Tt]est[Rr]esult*/
35 | [Bb]uild[Ll]og.*
36 |
37 | # NUNIT
38 | *.VisualState.xml
39 | TestResult.xml
40 |
41 | # Build Results of an ATL Project
42 | [Dd]ebugPS/
43 | [Rr]eleasePS/
44 | dlldata.c
45 |
46 | # DNX
47 | project.lock.json
48 | project.fragment.lock.json
49 | artifacts/
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # NCrunch
117 | _NCrunch_*
118 | .*crunch*.local.xml
119 | nCrunchTemp_*
120 |
121 | # MightyMoose
122 | *.mm.*
123 | AutoTest.Net/
124 |
125 | # Web workbench (sass)
126 | .sass-cache/
127 |
128 | # Installshield output folder
129 | [Ee]xpress/
130 |
131 | # DocProject is a documentation generator add-in
132 | DocProject/buildhelp/
133 | DocProject/Help/*.HxT
134 | DocProject/Help/*.HxC
135 | DocProject/Help/*.hhc
136 | DocProject/Help/*.hhk
137 | DocProject/Help/*.hhp
138 | DocProject/Help/Html2
139 | DocProject/Help/html
140 |
141 | # Click-Once directory
142 | publish/
143 |
144 | # Publish Web Output
145 | *.[Pp]ublish.xml
146 | *.azurePubxml
147 | # TODO: Comment the next line if you want to checkin your web deploy settings
148 | # but database connection strings (with potential passwords) will be unencrypted
149 | *.pubxml
150 | *.publishproj
151 |
152 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
153 | # checkin your Azure Web App publish settings, but sensitive information contained
154 | # in these scripts will be unencrypted
155 | PublishScripts/
156 |
157 | # NuGet Packages
158 | *.nupkg
159 | # The packages folder can be ignored because of Package Restore
160 | **/packages/*
161 | # except build/, which is used as an MSBuild target.
162 | !**/packages/build/
163 | # Uncomment if necessary however generally it will be regenerated when needed
164 | #!**/packages/repositories.config
165 | # NuGet v3's project.json files produces more ignoreable files
166 | *.nuget.props
167 | *.nuget.targets
168 |
169 | # Microsoft Azure Build Output
170 | csx/
171 | *.build.csdef
172 |
173 | # Microsoft Azure Emulator
174 | ecf/
175 | rcf/
176 |
177 | # Windows Store app package directories and files
178 | AppPackages/
179 | BundleArtifacts/
180 | Package.StoreAssociation.xml
181 | _pkginfo.txt
182 |
183 | # Visual Studio cache files
184 | # files ending in .cache can be ignored
185 | *.[Cc]ache
186 | # but keep track of directories ending in .cache
187 | !*.[Cc]ache/
188 |
189 | # Others
190 | ClientBin/
191 | ~$*
192 | *~
193 | *.dbmdl
194 | *.dbproj.schemaview
195 | *.pfx
196 | *.publishsettings
197 | node_modules/
198 | orleans.codegen.cs
199 |
200 | # Since there are multiple workflows, uncomment next line to ignore bower_components
201 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
202 | #bower_components/
203 |
204 | # RIA/Silverlight projects
205 | Generated_Code/
206 |
207 | # Backup & report files from converting an old project file
208 | # to a newer Visual Studio version. Backup files are not needed,
209 | # because we have git ;-)
210 | _UpgradeReport_Files/
211 | Backup*/
212 | UpgradeLog*.XML
213 | UpgradeLog*.htm
214 |
215 | # SQL Server files
216 | *.mdf
217 | *.ldf
218 |
219 | # Business Intelligence projects
220 | *.rdl.data
221 | *.bim.layout
222 | *.bim_*.settings
223 |
224 | # Microsoft Fakes
225 | FakesAssemblies/
226 |
227 | # GhostDoc plugin setting file
228 | *.GhostDoc.xml
229 |
230 | # Node.js Tools for Visual Studio
231 | .ntvs_analysis.dat
232 |
233 | # Visual Studio 6 build log
234 | *.plg
235 |
236 | # Visual Studio 6 workspace options file
237 | *.opt
238 |
239 | # Visual Studio LightSwitch build output
240 | **/*.HTMLClient/GeneratedArtifacts
241 | **/*.DesktopClient/GeneratedArtifacts
242 | **/*.DesktopClient/ModelManifest.xml
243 | **/*.Server/GeneratedArtifacts
244 | **/*.Server/ModelManifest.xml
245 | _Pvt_Extensions
246 |
247 | # Paket dependency manager
248 | .paket/paket.exe
249 | paket-files/
250 |
251 | # FAKE - F# Make
252 | .fake/
253 |
254 | # JetBrains Rider
255 | .idea/
256 | *.sln.iml
257 |
258 |
259 |
260 | ###### -- Custom Ignore Section, Make sure all files you add to the git repo are below this line -- ######
261 |
262 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules'
4 | dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none
5 | # SA0001: XML comment analysis is disabled due to project configuration
6 | dotnet_diagnostic.SA0001.severity = none
7 |
8 | # CA1062: Validate arguments of public methods
9 | dotnet_diagnostic.CA1062.severity = none
10 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/App.xaml:
--------------------------------------------------------------------------------
1 |
5 | UiTestWindows/ExplicitRowsAndColumnsLastRowWindow.xaml
6 |
7 |
8 |
12 |
13 |
22 |
23 |
31 |
32 |
36 |
37 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System;
4 | using System.Windows;
5 |
6 | ///
7 | /// Interaction logic for App.xaml.
8 | ///
9 | public partial class App : Application
10 | {
11 | protected override void OnStartup(StartupEventArgs e)
12 | {
13 | if (e is { Args: { Length: 1 } args })
14 | {
15 | var window = args[0];
16 | this.StartupUri = new Uri($"UiTestWindows/{window}.xaml", UriKind.Relative);
17 | }
18 |
19 | base.OnStartup(e);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 |
4 | [assembly: CLSCompliant(false)]
5 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
6 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/AutoIncrementColumnsView.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/AutoIncrementColumnsView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | public partial class AutoIncrementColumnsView : UserControl
6 | {
7 | public AutoIncrementColumnsView()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/ColumnDefinitionsView.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/ColumnDefinitionsView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | public partial class ColumnDefinitionsView : UserControl
6 | {
7 | public ColumnDefinitionsView()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/ColumnSpanView.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/ColumnSpanView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | public partial class ColumnSpanView : UserControl
6 | {
7 | public ColumnSpanView()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/ExplicitColumnsView.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/ExplicitColumnsView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | public partial class ExplicitColumnsView : UserControl
6 | {
7 | public ExplicitColumnsView()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/Gu.Wpf.AutoRowGrid.Demo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net6.0-windows
5 | true
6 | latest
7 |
8 |
9 |
10 | True
11 | AllEnabledByDefault
12 | latest
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/Gu.Wpf.AutoRowGrid.Demo.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | True
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/LastRowFillView.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/LastRowFillView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | public partial class LastRowFillView : UserControl
6 | {
7 | public LastRowFillView()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | ///
6 | /// Interaction logic for MainWindow.xaml.
7 | ///
8 | public partial class MainWindow : Window
9 | {
10 | public MainWindow()
11 | {
12 | this.InitializeComponent();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/NestedRowsView.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/NestedRowsView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | public partial class NestedRowsView : UserControl
6 | {
7 | public NestedRowsView()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/RowHeightView.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
25 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
46 |
47 |
48 |
49 |
50 |
51 |
54 |
57 |
58 |
59 |
60 |
63 |
64 |
67 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/RowHeightView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | ///
6 | /// Interaction logic for RowHeightView.xaml.
7 | ///
8 | public partial class RowHeightView : UserControl
9 | {
10 | public RowHeightView()
11 | {
12 | this.InitializeComponent();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/SandBoxView.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/SandBoxView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows.Controls;
4 |
5 | public partial class SandBoxView : UserControl
6 | {
7 | public SandBoxView()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsAndColumnsExplicitHeightWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsAndColumnsExplicitHeightWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | public partial class AutoRowsAndColumnsExplicitHeightWindow : Window
6 | {
7 | public AutoRowsAndColumnsExplicitHeightWindow()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsAndColumnsExplicitStarHeightWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsAndColumnsExplicitStarHeightWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | public partial class AutoRowsAndColumnsExplicitStarHeightWindow : Window
6 | {
7 | public AutoRowsAndColumnsExplicitStarHeightWindow()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsAndColumnsWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsAndColumnsWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | ///
6 | /// Interaction logic for AutoRowsAndColumnsWindow.xaml.
7 | ///
8 | public partial class AutoRowsAndColumnsWindow : Window
9 | {
10 | public AutoRowsAndColumnsWindow()
11 | {
12 | this.InitializeComponent();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsLastRowFillWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/AutoRowsLastRowFillWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | public partial class AutoRowsLastRowFillWindow : Window
6 | {
7 | public AutoRowsLastRowFillWindow()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/ExplicitRowsAndColumnsLastRowWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
26 |
30 |
31 |
36 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/ExplicitRowsAndColumnsLastRowWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | public partial class ExplicitRowsAndColumnsLastRowWindow : Window
6 | {
7 | public ExplicitRowsAndColumnsLastRowWindow()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/ExplicitRowsAndColumnsWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
28 |
29 |
34 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/ExplicitRowsAndColumnsWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | ///
6 | /// Interaction logic for ExplicitRowsAndColumnsWindow.xaml.
7 | ///
8 | public partial class ExplicitRowsAndColumnsWindow : Window
9 | {
10 | public ExplicitRowsAndColumnsWindow()
11 | {
12 | this.InitializeComponent();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/NestedRowsExplicitHeightWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/NestedRowsExplicitHeightWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | public partial class NestedRowsExplicitHeightWindow : Window
6 | {
7 | public NestedRowsExplicitHeightWindow()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/NestedRowsWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/NestedRowsWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Windows;
4 |
5 | public partial class NestedRowsWindow : Window
6 | {
7 | public NestedRowsWindow()
8 | {
9 | this.InitializeComponent();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/TestElement.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System;
4 | using System.Linq;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Threading;
8 |
9 | public static class TestElement
10 | {
11 | public static readonly DependencyProperty AllNestedMarginsAndPaddingsProperty = DependencyProperty.RegisterAttached(
12 | "AllNestedMarginsAndPaddings",
13 | typeof(Thickness?),
14 | typeof(TestElement),
15 | new PropertyMetadata(
16 | default(Thickness?),
17 | (d, e) => OnTextBoxViewMarginChanged((FrameworkElement)d, (Thickness?)e.NewValue)));
18 |
19 | /// Helper for setting on .
20 | /// to set on.
21 | /// AllNestedMarginsAndPaddings property value.
22 | public static void SetAllNestedMarginsAndPaddings(this FrameworkElement element, Thickness? value)
23 | {
24 | if (element is null)
25 | {
26 | throw new ArgumentNullException(nameof(element));
27 | }
28 |
29 | element.SetValue(AllNestedMarginsAndPaddingsProperty, value);
30 | }
31 |
32 | /// Helper for getting from .
33 | /// to read from.
34 | /// AllNestedMarginsAndPaddings property value.
35 | [AttachedPropertyBrowsableForChildren(IncludeDescendants = false)]
36 | [AttachedPropertyBrowsableForType(typeof(FrameworkElement))]
37 | public static Thickness? GetAllNestedMarginsAndPaddings(this FrameworkElement element)
38 | {
39 | if (element is null)
40 | {
41 | throw new ArgumentNullException(nameof(element));
42 | }
43 |
44 | return (Thickness?)element.GetValue(AllNestedMarginsAndPaddingsProperty);
45 | }
46 |
47 | private static void OnTextBoxViewMarginChanged(FrameworkElement textBox, Thickness? thickness)
48 | {
49 | if (!textBox.IsLoaded)
50 | {
51 | _ = textBox.Dispatcher.BeginInvoke(
52 | DispatcherPriority.Loaded,
53 | new Action(() => OnTextBoxViewMarginChanged(textBox, thickness)));
54 | return;
55 | }
56 |
57 | foreach (var child in textBox.NestedChildren().OfType())
58 | {
59 | if (thickness is null)
60 | {
61 | child.ClearValue(FrameworkElement.MarginProperty);
62 | }
63 | else
64 | {
65 | child.SetCurrentValue(FrameworkElement.MarginProperty, thickness.Value);
66 | }
67 | }
68 |
69 | foreach (var child in textBox.NestedChildren().OfType())
70 | {
71 | if (thickness is null)
72 | {
73 | child.ClearValue(Control.PaddingProperty);
74 | }
75 | else
76 | {
77 | child.SetCurrentValue(Control.PaddingProperty, thickness.Value);
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/TextBoxView.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System;
4 | using System.Linq;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Threading;
8 |
9 | public static class TextBoxView
10 | {
11 | public static readonly DependencyProperty MarginProperty = DependencyProperty.RegisterAttached(
12 | "Margin",
13 | typeof(Thickness?),
14 | typeof(TextBoxView),
15 | new PropertyMetadata(
16 | null,
17 | (d, e) => OnMarginChanged((TextBox)d, (Thickness?)e.NewValue)));
18 |
19 | public static Type Type { get; } = typeof(TextBox).Assembly.GetTypes().Single(x => x.Name == "TextBoxView");
20 |
21 | /// Helper for setting on .
22 | /// to set on.
23 | /// Margin property value.
24 | public static void SetMargin(TextBox element, Thickness? value)
25 | {
26 | if (element is null)
27 | {
28 | throw new ArgumentNullException(nameof(element));
29 | }
30 |
31 | element.SetValue(MarginProperty, value);
32 | }
33 |
34 | /// Helper for getting from .
35 | /// to read from.
36 | /// Margin property value.
37 | [AttachedPropertyBrowsableForChildren(IncludeDescendants = false)]
38 | [AttachedPropertyBrowsableForType(typeof(TextBox))]
39 | public static Thickness? GetMargin(TextBox element)
40 | {
41 | if (element is null)
42 | {
43 | throw new ArgumentNullException(nameof(element));
44 | }
45 |
46 | return (Thickness?)element.GetValue(MarginProperty);
47 | }
48 |
49 | private static void OnMarginChanged(TextBox textBox, Thickness? margin)
50 | {
51 | if (!textBox.IsLoaded)
52 | {
53 | _ = textBox.Dispatcher.BeginInvoke(
54 | DispatcherPriority.Loaded,
55 | new Action(() => OnMarginChanged(textBox, margin)));
56 | return;
57 | }
58 |
59 | var textBoxView = textBox.NestedChildren()
60 | .SingleOrDefault(x => x.GetType().Name == "TextBoxView");
61 | if (margin is null)
62 | {
63 | textBoxView?.ClearValue(FrameworkElement.MarginProperty);
64 | }
65 | else
66 | {
67 | textBoxView?.SetCurrentValue(FrameworkElement.MarginProperty, margin.Value);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/UiTestWindows/VisualTreeExt.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.Collections.Generic;
4 | using System.Windows;
5 | using System.Windows.Media;
6 |
7 | internal static class VisualTreeExt
8 | {
9 | internal static IEnumerable NestedChildren(this DependencyObject parent)
10 | {
11 | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
12 | {
13 | var child = VisualTreeHelper.GetChild(parent, i);
14 | yield return child;
15 | if (VisualTreeHelper.GetChildrenCount(child) == 0)
16 | {
17 | continue;
18 | }
19 |
20 | foreach (var nestedChild in NestedChildren(child))
21 | {
22 | yield return nestedChild;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.Demo/ViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.Demo;
2 |
3 | using System.ComponentModel;
4 | using System.Runtime.CompilerServices;
5 |
6 | public class ViewModel : INotifyPropertyChanged
7 | {
8 | private string value1 = "value 1";
9 | private string value2 = "value 2";
10 | private string value3 = "value 3";
11 | private string value4 = "value 4";
12 | private string value5 = "value 5";
13 | private string value6 = "value 6";
14 | private string value7 = "value 7";
15 |
16 | public event PropertyChangedEventHandler PropertyChanged;
17 |
18 | public string Value1
19 | {
20 | get => this.value1;
21 |
22 | set
23 | {
24 | if (value == this.value1)
25 | {
26 | return;
27 | }
28 |
29 | this.value1 = value;
30 | this.OnPropertyChanged();
31 | }
32 | }
33 |
34 | public string Value2
35 | {
36 | get => this.value2;
37 |
38 | set
39 | {
40 | if (value == this.value2)
41 | {
42 | return;
43 | }
44 |
45 | this.value2 = value;
46 | this.OnPropertyChanged();
47 | }
48 | }
49 |
50 | public string Value3
51 | {
52 | get => this.value3;
53 |
54 | set
55 | {
56 | if (value == this.value3)
57 | {
58 | return;
59 | }
60 |
61 | this.value3 = value;
62 | this.OnPropertyChanged();
63 | }
64 | }
65 |
66 | public string Value4
67 | {
68 | get => this.value4;
69 |
70 | set
71 | {
72 | if (value == this.value4)
73 | {
74 | return;
75 | }
76 |
77 | this.value4 = value;
78 | this.OnPropertyChanged();
79 | }
80 | }
81 |
82 | public string Value5
83 | {
84 | get => this.value5;
85 |
86 | set
87 | {
88 | if (value == this.value5)
89 | {
90 | return;
91 | }
92 |
93 | this.value5 = value;
94 | this.OnPropertyChanged();
95 | }
96 | }
97 |
98 | public string Value6
99 | {
100 | get => this.value6;
101 |
102 | set
103 | {
104 | if (value == this.value6)
105 | {
106 | return;
107 | }
108 |
109 | this.value6 = value;
110 | this.OnPropertyChanged();
111 | }
112 | }
113 |
114 | public string Value7
115 | {
116 | get => this.value7;
117 |
118 | set
119 | {
120 | if (value == this.value7)
121 | {
122 | return;
123 | }
124 |
125 | this.value7 = value;
126 | this.OnPropertyChanged();
127 | }
128 | }
129 |
130 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
131 | {
132 | this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules'
4 | dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none
5 |
6 | # SA0001: XML comment analysis is disabled due to project configuration
7 | dotnet_diagnostic.SA0001.severity = none
8 |
9 | # CA1303: Do not pass literals as localized parameters
10 | dotnet_diagnostic.CA1303.severity = none
11 |
12 | # CA1062: Validate arguments of public methods
13 | dotnet_diagnostic.CA1062.severity = none
14 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/AutoRowsAndColumnsExplicitHeightTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class AutoRowsAndColumnsExplicitHeightTests
7 | {
8 | private const string WindowName = "AutoRowsAndColumnsExplicitHeightWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,100", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,100", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,100 35,200", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,100 150,200", window.GetItemPosition("R1C1"));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/AutoRowsAndColumnsExplicitStarHeightTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class AutoRowsAndColumnsExplicitStarHeightTests
7 | {
8 | private const string WindowName = "AutoRowsAndColumnsExplicitStarHeightWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,100", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,100", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,100 35,200", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,100 150,200", window.GetItemPosition("R1C1"));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/AutoRowsAndColumnsWindowTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class AutoRowsAndColumnsTests
7 | {
8 | private const string WindowName = "AutoRowsAndColumnsWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,18", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,18", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,18 35,36", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,18 150,36", window.GetItemPosition("R1C1"));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/AutoRowsLastRowFillTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class AutoRowsLastRowFillTests
7 | {
8 | private const string WindowName = "AutoRowsLastRowFillWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,18", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,18", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,18 35,200", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,18 150,200", window.GetItemPosition("R1C1"));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/ExplicitRowsAndColumnsLastRowFillTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class ExplicitRowsAndColumnsLastRowFillTests
7 | {
8 | private const string WindowName = "ExplicitRowsAndColumnsLastRowWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,18", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,18", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,18 35,200", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,18 150,200", window.GetItemPosition("R1C1"));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/ExplicitRowsAndColumnsTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class ExplicitRowsAndColumnsTests
7 | {
8 | private const string WindowName = "ExplicitRowsAndColumnsWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,18", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,18", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,18 35,36", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,18 150,36", window.GetItemPosition("R1C1"));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/Gu.Wpf.AutoRowGrid.UiTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | true
6 | latest
7 |
8 |
9 |
10 | True
11 | AllEnabledByDefault
12 | latest
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/Gu.Wpf.AutoRowGrid.UiTests.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/Helpers/WindowExt.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using System.Globalization;
4 | using Gu.Wpf.UiAutomation;
5 |
6 | public static class WindowExt
7 | {
8 | public static string GetItemPosition(this Window window, string name)
9 | {
10 | var groupBox = window.FindGroupBox();
11 | var item = groupBox.FindFirstDescendant(Conditions.ByAutomationId(name));
12 | var topLeft = item.Bounds.TopLeft - groupBox.Bounds.TopLeft;
13 | var bottomRight = item.Bounds.BottomRight - groupBox.Bounds.TopLeft;
14 | return $"{topLeft.ToString(CultureInfo.InvariantCulture)} {bottomRight.ToString(CultureInfo.InvariantCulture)}";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/NestedRowsExplicitHeightTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class NestedRowsExplicitHeightTests
7 | {
8 | private const string WindowName = "NestedRowsExplicitHeightWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,25", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,25", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,25 35,50", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,25 150,50", window.GetItemPosition("R1C1"));
19 | Assert.AreEqual("0,50 35,80", window.GetItemPosition("R2C0"));
20 | Assert.AreEqual("35,50 150,80", window.GetItemPosition("R2C1"));
21 | Assert.AreEqual("0,80 35,110", window.GetItemPosition("R3C0"));
22 | Assert.AreEqual("35,80 150,110", window.GetItemPosition("R3C1"));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.UiTests/NestedRowsTests.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid.UiTests;
2 |
3 | using Gu.Wpf.UiAutomation;
4 | using NUnit.Framework;
5 |
6 | public class NestedRowsTests
7 | {
8 | private const string WindowName = "NestedRowsWindow";
9 |
10 | [Test]
11 | public void Bounds()
12 | {
13 | using var app = Application.Launch("Gu.Wpf.AutoRowGrid.Demo.exe", WindowName);
14 | var window = app.MainWindow;
15 | Assert.AreEqual("0,0 35,18", window.GetItemPosition("R0C0"));
16 | Assert.AreEqual("35,0 150,18", window.GetItemPosition("R0C1"));
17 | Assert.AreEqual("0,18 35,36", window.GetItemPosition("R1C0"));
18 | Assert.AreEqual("35,18 150,36", window.GetItemPosition("R1C1"));
19 | Assert.AreEqual("0,36 35,54", window.GetItemPosition("R2C0"));
20 | Assert.AreEqual("35,36 150,54", window.GetItemPosition("R2C1"));
21 | Assert.AreEqual("0,54 35,72", window.GetItemPosition("R3C0"));
22 | Assert.AreEqual("35,54 150,72", window.GetItemPosition("R3C1"));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29728.190
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".sln", ".sln", "{AF6E6D40-FE2C-4077-A4D8-D22587491C9C}"
7 | ProjectSection(SolutionItems) = preProject
8 | .editorconfig = .editorconfig
9 | .gitignore = .gitignore
10 | appveyor.yml = appveyor.yml
11 | azure-pipelines.yml = azure-pipelines.yml
12 | Gu.Wpf.AutoRowGrid.sln.DotSettings = Gu.Wpf.AutoRowGrid.sln.DotSettings
13 | EndProjectSection
14 | EndProject
15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gu.Wpf.AutoRowGrid", "Gu.Wpf.AutoRowGrid\Gu.Wpf.AutoRowGrid.csproj", "{AF8CBE62-B44A-4E61-90F6-5453651C16A4}"
16 | EndProject
17 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gu.Wpf.AutoRowGrid.Demo", "Gu.Wpf.AutoRowGrid.Demo\Gu.Wpf.AutoRowGrid.Demo.csproj", "{F6E3564A-31A6-4958-AB8F-939AFDF78E6A}"
18 | EndProject
19 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".docs", ".docs", "{68C4DDDA-EAF5-49D1-941A-1245571C827D}"
20 | ProjectSection(SolutionItems) = preProject
21 | LICENSE = LICENSE
22 | README.md = README.md
23 | RELEASE_NOTES.md = RELEASE_NOTES.md
24 | EndProjectSection
25 | EndProject
26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gu.Wpf.AutoRowGrid.UiTests", "Gu.Wpf.AutoRowGrid.UiTests\Gu.Wpf.AutoRowGrid.UiTests.csproj", "{3641AF56-78F7-409A-9A4D-7E8AB5D9509D}"
27 | EndProject
28 | Global
29 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
30 | Debug|Any CPU = Debug|Any CPU
31 | Release|Any CPU = Release|Any CPU
32 | EndGlobalSection
33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
34 | {AF8CBE62-B44A-4E61-90F6-5453651C16A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {AF8CBE62-B44A-4E61-90F6-5453651C16A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {AF8CBE62-B44A-4E61-90F6-5453651C16A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {AF8CBE62-B44A-4E61-90F6-5453651C16A4}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {F6E3564A-31A6-4958-AB8F-939AFDF78E6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {F6E3564A-31A6-4958-AB8F-939AFDF78E6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {F6E3564A-31A6-4958-AB8F-939AFDF78E6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {F6E3564A-31A6-4958-AB8F-939AFDF78E6A}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {3641AF56-78F7-409A-9A4D-7E8AB5D9509D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {3641AF56-78F7-409A-9A4D-7E8AB5D9509D}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {3641AF56-78F7-409A-9A4D-7E8AB5D9509D}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {3641AF56-78F7-409A-9A4D-7E8AB5D9509D}.Release|Any CPU.Build.0 = Release|Any CPU
46 | EndGlobalSection
47 | GlobalSection(SolutionProperties) = preSolution
48 | HideSolutionNode = FALSE
49 | EndGlobalSection
50 | GlobalSection(ExtensibilityGlobals) = postSolution
51 | SolutionGuid = {457FC9F9-0559-401D-BD90-0FF49F5907B9}
52 | EndGlobalSection
53 | EndGlobal
54 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | True
4 | ShowAndRun
5 | Field, Property, Event, Method
6 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
7 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
8 | True
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # SA1633: File should have header
4 | dotnet_diagnostic.SA1633.severity = none
5 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Markup;
4 |
5 | [assembly: CLSCompliant(false)]
6 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
7 | [assembly: XmlnsDefinition("http://gu.se/AutoRowGrid", "Gu.Wpf.AutoRowGrid")]
8 | [assembly: XmlnsPrefix("http://gu.se/AutoRowGrid", "autoRowGrid")]
9 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/AutoIncrement.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid;
2 |
3 | using System.Windows;
4 |
5 | /// Provides an attached proerpty fro setting autoincrementation for an .
6 | public static class AutoIncrement
7 | {
8 | /// An attached property for setting on a single element.
9 | public static readonly DependencyProperty AutoIncrementationProperty = DependencyProperty.RegisterAttached(
10 | "AutoIncrementation",
11 | typeof(AutoIncrementation),
12 | typeof(AutoIncrement),
13 | new FrameworkPropertyMetadata(AutoIncrementation.Inherit, FrameworkPropertyMetadataOptions.NotDataBindable));
14 |
15 | /// Helper for setting on .
16 | /// to set on.
17 | /// AutoIncrementation property value.
18 | public static void SetAutoIncrementation(this UIElement element, AutoIncrementation value)
19 | {
20 | if (element is null)
21 | {
22 | throw new System.ArgumentNullException(nameof(element));
23 | }
24 |
25 | element.SetValue(AutoIncrementationProperty, value);
26 | }
27 |
28 | /// Helper for getting from .
29 | /// to read from.
30 | /// AutoIncrementation property value.
31 | [AttachedPropertyBrowsableForChildren(IncludeDescendants = false)]
32 | [AttachedPropertyBrowsableForType(typeof(UIElement))]
33 | public static AutoIncrementation GetAutoIncrementation(this UIElement element)
34 | {
35 | if (element is null)
36 | {
37 | throw new System.ArgumentNullException(nameof(element));
38 | }
39 |
40 | return (AutoIncrementation)element.GetValue(AutoIncrementationProperty);
41 | }
42 |
43 | // If self is Inherit use
44 | internal static AutoIncrementation CoerceWith(this AutoIncrementation self, AutoIncrementation parentValue)
45 | {
46 | if (self == AutoIncrementation.Inherit)
47 | {
48 | return parentValue;
49 | }
50 |
51 | return self;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/AutoIncrementation.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid;
2 |
3 | /// What auto incrementation strategy to use.
4 | public enum AutoIncrementation
5 | {
6 | /// Inherit setting from parent.
7 | Inherit,
8 |
9 | /// children of a get column index from position in the collection.
10 | AutoIncrement,
11 |
12 | /// Grid.Column="n" is specified manually in XAML.
13 | UseExplicitColumns,
14 | }
15 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/ColumnDefinitions/ColumnDefinitions.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid;
2 |
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.ComponentModel;
6 |
7 | ///
8 | /// is sealed with internal ctor. Hence this class.
9 | /// Only used as a returnvalue from .
10 | ///
11 | [TypeConverter(typeof(ColumnDefinitionsConverter))]
12 | public class ColumnDefinitions : Collection
13 | {
14 | /// Initializes a new instance of the class.
15 | public ColumnDefinitions()
16 | {
17 | }
18 |
19 | /// Initializes a new instance of the class.
20 | /// The .
21 | public ColumnDefinitions(IList collection)
22 | : base(collection)
23 | {
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/ColumnDefinitions/ColumnDefinitionsConverter.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid;
2 |
3 | using System;
4 | using System.ComponentModel;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Security;
8 |
9 | ///
10 | public class ColumnDefinitionsConverter : TypeConverter
11 | {
12 | ///
13 | public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
14 | {
15 | return sourceType == typeof(string);
16 | }
17 |
18 | ///
19 | public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
20 | {
21 | return false;
22 | }
23 |
24 | ///
25 | public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
26 | {
27 | if (value is string text)
28 | {
29 | var lengths = GridLengthsParser.Parse(context, culture, text);
30 | var columnDefinitions = lengths.Select(gl => new System.Windows.Controls.ColumnDefinition { Width = gl })
31 | .ToArray();
32 | return new ColumnDefinitions(columnDefinitions);
33 | }
34 |
35 | return base.ConvertFrom(context, culture, value);
36 | }
37 |
38 | ///
39 | public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
40 | {
41 | throw new NotSupportedException();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/ColumnDefinitions/GridLengthsParser.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid;
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.ComponentModel;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Windows;
9 |
10 | internal static class GridLengthsParser
11 | {
12 | private static readonly GridLengthConverter GridLengthConverter = new();
13 | private static readonly char[] SeparatorChars = { ',', ' ' };
14 |
15 | internal static IEnumerable Parse(ITypeDescriptorContext? typeDescriptorContext, CultureInfo? cultureInfo, string text)
16 | {
17 | try
18 | {
19 | var lengths = text.Split(SeparatorChars, StringSplitOptions.RemoveEmptyEntries)
20 | .Select(x => (GridLength)GridLengthConverter.ConvertFrom(typeDescriptorContext, cultureInfo, x));
21 | return lengths;
22 | }
23 | catch (Exception e)
24 | {
25 | var message = $"Could not parse gridlengts from {text}.\r\n" +
26 | $"Expected a string like '* 20 Auto'\r\n" +
27 | $"Valid separators are {{{string.Join(", ", SeparatorChars.Select(x => $"'x'"))}}}";
28 | throw new FormatException(message, e);
29 | }
30 | }
31 |
32 | // http://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/GridLengthConverter.cs,218
33 | internal static string ToString(GridLength gl, CultureInfo cultureInfo)
34 | {
35 | return gl.GridUnitType switch
36 | {
37 | // for Auto print out "Auto". value is always "1.0"
38 | GridUnitType.Auto => "Auto",
39 |
40 | // Star has one special case when value is "1.0".
41 | // in this case drop value part and print only "Star"
42 | GridUnitType.Star => IsOne(gl.Value)
43 | ? "*"
44 | : Convert.ToString(gl.Value, cultureInfo) + "*",
45 |
46 | // for Pixel print out the numeric value. "px" can be omitted.
47 | _ => Convert.ToString(gl.Value, cultureInfo),
48 | };
49 | }
50 |
51 | // http://referencesource.microsoft.com/#WindowsBase/Shared/MS/Internal/DoubleUtil.cs,8e95e6558bdb123d
52 | private static bool IsOne(double value)
53 | {
54 | const double DblEpsilon = 2.2204460492503131e-016;
55 | return Math.Abs(value - 1.0) < 10.0 * DblEpsilon;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Gu.Wpf.AutoRowGrid/GridExtension.cs:
--------------------------------------------------------------------------------
1 | namespace Gu.Wpf.AutoRowGrid;
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Collections.ObjectModel;
6 | using System.ComponentModel;
7 | using System.Linq;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Markup;
11 |
12 | /// Helper for creating .
13 | [MarkupExtensionReturnType(typeof(Grid))]
14 | [ContentProperty(nameof(Rows))]
15 | [DefaultProperty(nameof(Rows))]
16 | public class GridExtension : MarkupExtension
17 | {
18 | ///
19 | /// Gets or sets a value that specifies if content of rows will get column index from index.
20 | /// Default is Increment.
21 | /// This will be used for all sub-nodes that have Inherit.
22 | ///
23 | public static AutoIncrementation GlobalAutoIncrementation { get; set; } = AutoIncrementation.AutoIncrement;
24 |
25 | #pragma warning disable CA2227 // Collection properties should be read only
26 | /// Gets or sets see .
27 | public ColumnDefinitions ColumnDefinitions { get; set; } = new ColumnDefinitions();
28 | #pragma warning restore CA2227 // Collection properties should be read only
29 |
30 | ///
31 | /// Gets or sets a value for what height should be used when generating rows for the grid.
32 | /// Default is Auto.
33 | ///
34 | public GridLength RowHeight { get; set; } = GridLength.Auto;
35 |
36 | ///
37 | /// Gets or sets a value that specifies if content of rows will get column index from index.
38 | /// Default is Increment.
39 | ///
40 | public AutoIncrementation AutoIncrementation { get; set; } = GlobalAutoIncrementation;
41 |
42 | ///
43 | /// Gets or sets a value indicating whether gets or sets a value indicating how the last row is handled.
44 | /// If true tha last row gets Height = "*".
45 | /// If false an extra row with Height = "*" is added to fill remaining space.
46 | public bool LastRowFill { get; set; }
47 |
48 | #pragma warning disable CA2227 // Collection properties should be read only
49 | /// Gets or sets the children that are used when creating the grid.
50 | public ChildCollection Rows { get; set; } = new ChildCollection();
51 | #pragma warning restore CA2227 // Collection properties should be read only
52 |
53 | ///
54 | public override object ProvideValue(IServiceProvider serviceProvider)
55 | {
56 | var grid = new Grid();
57 | this.Rows.Inherit(this.AutoIncrementation, this.RowHeight);
58 | AddRowsRecursive(grid, this.Rows, this.RowHeight);
59 | if (grid.RowDefinitions.All(x => !x.Height.IsStar))
60 | {
61 | if (this.LastRowFill)
62 | {
63 | grid.RowDefinitions[grid.RowDefinitions.Count - 1].SetCurrentValue(RowDefinition.HeightProperty, new GridLength(1, GridUnitType.Star));
64 | }
65 | else
66 | {
67 | grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
68 | }
69 | }
70 |
71 | if (this.ColumnDefinitions != null)
72 | {
73 | foreach (var columnDefinition in this.ColumnDefinitions)
74 | {
75 | grid.ColumnDefinitions.Add(columnDefinition);
76 | }
77 | }
78 |
79 | return grid;
80 | }
81 |
82 | private static void AddRowsRecursive(Grid grid, IEnumerable