budul.AvaloniaGridDefinitionBehavoir
1.1.1
dotnet add package budul.AvaloniaGridDefinitionBehavoir --version 1.1.1
NuGet\Install-Package budul.AvaloniaGridDefinitionBehavoir -Version 1.1.1
<PackageReference Include="budul.AvaloniaGridDefinitionBehavoir" Version="1.1.1" />
paket add budul.AvaloniaGridDefinitionBehavoir --version 1.1.1
#r "nuget: budul.AvaloniaGridDefinitionBehavoir, 1.1.1"
// Install budul.AvaloniaGridDefinitionBehavoir as a Cake Addin #addin nuget:?package=budul.AvaloniaGridDefinitionBehavoir&version=1.1.1 // Install budul.AvaloniaGridDefinitionBehavoir as a Cake Tool #tool nuget:?package=budul.AvaloniaGridDefinitionBehavoir&version=1.1.1
AvaloniaGridDefinitionBehavoir
This behavior allows the adjustment of the RowDefinitions / ColumnDefinitions of Avalonia Grids. It was inspired by a blog entry by Rachel Lim. This approach was initially shown for WPF Grids.
The behavior is available as NuGet package.
Useage
The following code ...
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
</Grid>
... can be defined as follows:
<Grid
avaloniaGridDefinitionBehavoir:GridDefinitionBehavior.RowCount="4"
avaloniaGridDefinitionBehavoir:GridDefinitionBehavior.ColumnCount="2">
</Grid>
Definitions with stars must be set additionally by using regular expressions. The following output ...
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
... can be defined as follows:
<Grid
avaloniaGridDefinitionBehavoir:GridDefinitionBehavior.RowCount="4"
avaloniaGridDefinitionBehavoir:GridDefinitionBehavior.ColumnCount="2"
avaloniaGridDefinitionBehavoir:GridDefinitionBehavior.StarRows="\d*[13579]"
avaloniaGridDefinitionBehavoir:GridDefinitionBehavior.StarColumns=".*">
</Grid>
For MVVM apps the grid definitions can also be bound onto the view models. The following can be seen in the sample data.
<ItemsControl
x:DataType="vm:MainWindowViewModel"
DockPanel.Dock="Top"
ItemsSource="{Binding Elements}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
gridbehavior:GridDefinitionBehavior.ColumnCount="{Binding Columns}"
gridbehavior:GridDefinitionBehavior.RowCount="{Binding Rows}"
ShowGridLines="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Styles>
<Style x:DataType="md:Element" Selector="ItemsControl > ContentPresenter">
<Setter Property="Grid.Row" Value="{Binding Row}" />
<Setter Property="Grid.Column" Value="{Binding Column}" />
</Style>
</ItemsControl.Styles>
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="md:Element">
<TextBlock Margin="10" Text="{Binding Name}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Avalonia (>= 11.0.7)
- Avalonia.ReactiveUI (>= 11.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.