Skip to content

Commit

Permalink
feat(sample): add grid
Browse files Browse the repository at this point in the history
  • Loading branch information
giard-alexandre committed Jun 25, 2024
1 parent b2ba015 commit 77da326
Show file tree
Hide file tree
Showing 7 changed files with 415 additions and 88 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Avalonia" Version="11.0.11" />
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.0.11" />
<PackageVersion Include="Avalonia.Desktop" Version="11.0.11" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.0.11" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.0.11" />
Expand Down
3 changes: 2 additions & 1 deletion samples/Fonts.Avalonia.Samples/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
</Application.Styles>
</Application>
</Application>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Controls.DataGrid" />
<PackageReference Include="Avalonia.Desktop" />
<PackageReference Include="Avalonia.Themes.Fluent" />
<PackageReference Include="Avalonia.Fonts.Inter" />
Expand Down
192 changes: 105 additions & 87 deletions samples/Fonts.Avalonia.Samples/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,119 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:samples="clr-namespace:Fonts.Avalonia.Samples"
xmlns:models="clr-namespace:Fonts.Avalonia.Samples.Models"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800"
x:Class="Fonts.Avalonia.Samples.MainWindow"
Title="Fonts.Avalonia.Samples">
<StackPanel Margin="10,10,-10,0" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<StackPanel>
<TextBlock Text="Default Button" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<Button Content="Enabled" />
<Button Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="Toggle Button" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<ToggleButton Content="Enabled" />
<ToggleButton Content="Checked" IsChecked="True" Margin="0,5,0,0" />
<ToggleButton Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<ToggleButton Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel>
<TextBlock Text="Toggle Switch" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<ToggleSwitch Content="Enabled" />
<ToggleSwitch Content="Checked" IsChecked="True" Margin="0,5,0,0" />
<ToggleSwitch Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<ToggleSwitch Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="CheckBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<CheckBox Content="Enabled" />
<CheckBox Content="Checked" IsChecked="True" Margin="0,5,0,0" />
<CheckBox Content="3-State" IsChecked="{x:Null}" IsThreeState="True" Margin="0,5,0,0" />
<CheckBox Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<CheckBox Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
<CheckBox Content="3-State" IsChecked="{x:Null}" IsThreeState="True" IsEnabled="False"
Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="RadioButton" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<ScrollViewer>
<StackPanel Margin="10,10,-10,0" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<StackPanel>
<RadioButton Content="Enabled" />
<RadioButton Content="Checked" IsChecked="True" Margin="0,5,0,0" />
<TextBlock Text="Default Button" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<Button Content="Enabled" />
<Button Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="Toggle Button" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<ToggleButton Content="Enabled" />
<ToggleButton Content="Checked" IsChecked="True" Margin="0,5,0,0" />
<ToggleButton Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<ToggleButton Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel>
<RadioButton Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<RadioButton Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
<TextBlock Text="Toggle Switch" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<ToggleSwitch Content="Enabled" />
<ToggleSwitch Content="Checked" IsChecked="True" Margin="0,5,0,0" />
<ToggleSwitch Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<ToggleSwitch Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="CheckBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<CheckBox Content="Enabled" />
<CheckBox Content="Checked" IsChecked="True" Margin="0,5,0,0" />
<CheckBox Content="3-State" IsChecked="{x:Null}" IsThreeState="True" Margin="0,5,0,0" />
<CheckBox Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<CheckBox Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
<CheckBox Content="3-State" IsChecked="{x:Null}" IsThreeState="True" IsEnabled="False"
Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="RadioButton" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<StackPanel>
<RadioButton Content="Enabled" />
<RadioButton Content="Checked" IsChecked="True" Margin="0,5,0,0" />
</StackPanel>
<StackPanel>
<RadioButton Content="Disabled" IsEnabled="False" Margin="0,5,0,0" />
<RadioButton Content="Checked" IsChecked="True" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,20,0,0">
<StackPanel>
<TextBlock Text="TextBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<TextBox Text="Enabled" />
<TextBox Watermark="Placeholder" Margin="0,5,0,0" />
<TextBox Text="Disabled" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="PasswordBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<TextBox PasswordChar="*" Text="Enabled" />
<TextBox PasswordChar="*" Watermark="Placeholder" Margin="0,5,0,0" />
<TextBox PasswordChar="*" Text="Disabled" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel>
<TextBlock Text="Slider" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<Slider Value="0" MinWidth="120" />
<Slider Value="1" TickPlacement="Outside" Margin="0,5,0,0" />
<Slider Value="2" IsDirectionReversed="True" TickPlacement="BottomRight" Margin="0,5,0,0" />
<Slider Value="5" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="ListBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<ListBox BorderThickness="1">
<ListBoxItem Content="Unselected" />
<ListBoxItem Content="Selected" />
<ListBoxItem Content="Disabled" IsEnabled="False" />
</ListBox>
<StackPanel Orientation="Horizontal" Margin="0,20,0,0">
<StackPanel>
<TextBlock Text="TextBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<TextBox Text="Enabled" />
<TextBox Watermark="Placeholder" Margin="0,5,0,0" />
<TextBox Text="Disabled" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="PasswordBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<TextBox PasswordChar="*" Text="Enabled" />
<TextBox PasswordChar="*" Watermark="Placeholder" Margin="0,5,0,0" />
<TextBox PasswordChar="*" Text="Disabled" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel>
<TextBlock Text="Slider" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<Slider Value="0" MinWidth="120" />
<Slider Value="1" TickPlacement="Outside" Margin="0,5,0,0" />
<Slider Value="2" IsDirectionReversed="True" TickPlacement="BottomRight" Margin="0,5,0,0" />
<Slider Value="5" IsEnabled="False" Margin="0,5,0,0" />
</StackPanel>
<StackPanel Margin="20,0">
<TextBlock Text="ListBox" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<ListBox BorderThickness="1">
<ListBoxItem Content="Unselected" />
<ListBoxItem Content="Selected" />
<ListBoxItem Content="Disabled" IsEnabled="False" />
</ListBox>
</StackPanel>
<StackPanel>
<TextBlock Text="TreeView" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<TreeView BorderThickness="1">
<TreeViewItem Header="Expanded" IsExpanded="True">
<TreeViewItem Header="Child" />
</TreeViewItem>
<TreeViewItem Header="Collapsed">
<TreeViewItem Header="Child" />
</TreeViewItem>
<TreeViewItem Header="Disabled" IsEnabled="False">
<TreeViewItem Header="Child" />
</TreeViewItem>
</TreeView>
</StackPanel>
</StackPanel>
<StackPanel>
<TextBlock Text="TreeView" FontSize="18" TextAlignment="Center" Margin="0,0,0,10" />
<TreeView BorderThickness="1">
<TreeViewItem Header="Expanded" IsExpanded="True">
<TreeViewItem Header="Child" />
</TreeViewItem>
<TreeViewItem Header="Collapsed">
<TreeViewItem Header="Child" />
</TreeViewItem>
<TreeViewItem Header="Disabled" IsEnabled="False">
<TreeViewItem Header="Child" />
</TreeViewItem>
</TreeView>
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<DataGrid Name="DataGrid1" CanUserResizeColumns="True" CanUserReorderColumns="True"
CanUserSortColumns="True" HeadersVisibility="All"
IsReadOnly="True" MinHeight="300">
<DataGrid.Columns>
<!-- Using HeaderTemplate -->
<DataGridTextColumn Header="Country or Region" Binding="{Binding Name}" Width="6*"
x:DataType="models:Country" />
<DataGridTextColumn Header="Region" Binding="{Binding Region}" Width="4*"
x:DataType="models:Country" />
<DataGridTextColumn Header="Population" Binding="{Binding Population}" Width="3*"
x:DataType="models:Country" />
<DataGridTextColumn Header="Area" Binding="{Binding Area}" Width="3*"
x:DataType="models:Country" />
<DataGridTextColumn Header="GDP" Binding="{Binding GDP}" Width="3*"
MinWidth="200"
MaxWidth="350"
x:DataType="models:Country" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</StackPanel>
<StackPanel>
<DataGrid Name="PersonGrid">
<DataGrid.Columns>
<DataGridTextColumn Header="Name"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Window>
4 changes: 4 additions & 0 deletions samples/Fonts.Avalonia.Samples/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Avalonia.Controls;

using Fonts.Avalonia.Samples.Models;

namespace Fonts.Avalonia.Samples;

public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();

DataGrid1.ItemsSource = Countries.All;
}
}
Loading

0 comments on commit 77da326

Please sign in to comment.