feat: layout calculation.

This commit is contained in:
rabbitism
2024-02-21 22:48:11 +08:00
parent ab4b74d055
commit 6f4e11c7f5
6 changed files with 166 additions and 34 deletions

View File

@@ -28,7 +28,6 @@ public class ToolBarItemTemplateSelector: IDataTemplate
{
[!ContentControl.ContentProperty] = new Binding() { Path = "Content" },
[!ToggleButton.IsCheckedProperty] = new Binding() { Path = "IsChecked" },
[!Button.CommandProperty] = new Binding() { Path = "Command" },
[!ToolBar.OverflowModeProperty] = new Binding(){ Path = "OverflowMode" }
};
}
@@ -39,7 +38,7 @@ public class ToolBarItemTemplateSelector: IDataTemplate
[!ContentControl.ContentProperty] = new Binding() { Path = "Content" },
[!SelectingItemsControl.SelectedItemProperty] = new Binding() { Path = "SelectedItem" },
[!ItemsControl.ItemsSourceProperty] = new Binding() { Path = "Items" },
[!ToolBar.OverflowModeProperty] = new Binding(){ Path = "OverflowMode" }
[ToolBar.OverflowModeProperty] = OverflowMode.Always,
};
}
return new Button() { Content = "Undefined Item" };

View File

@@ -10,15 +10,16 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Ursa.Demo.Pages.ToolBarDemo">
<StackPanel>
<u:ToolBar>
<u:ToolBar HorizontalAlignment="Left">
<Button Content="Button 1" />
<Button Content="Button 2" />
<Button Content="Button 3" />
<Button Content="Button 3" u:ToolBar.OverflowMode="Always" />
</u:ToolBar>
<u:ToolBar ItemsSource="{Binding Items}">
<u:ToolBar ItemsSource="{Binding Items}" HorizontalAlignment="Left">
<u:ToolBar.ItemTemplate>
<template:ToolBarItemTemplateSelector/>
</u:ToolBar.ItemTemplate>
</u:ToolBar>
<CheckBox Content="Check"></CheckBox>
</StackPanel>
</UserControl>

View File

@@ -1,4 +1,5 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace Ursa.Demo.Views;