diff --git a/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.axaml b/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.axaml index 0ce51ca..4c486c3 100644 --- a/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.axaml +++ b/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.axaml @@ -2,27 +2,168 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:Toolkit.UI.Controls.Avalonia"> + + + + + + + + + 6 + 40 + 40 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + diff --git a/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.cs b/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.cs index bde03d4..506f357 100644 --- a/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.cs +++ b/Toolkit.UI.Controls.Avalonia/Overflow/Overflow.cs @@ -48,20 +48,6 @@ public class Overflow : .AddClassHandler(OnSecondarySelectionPropertyChanged); } - private void OnPrimarySelectionPropertyChanged(OverflowTemplateSettings sender, - AvaloniaPropertyChangedEventArgs args) - { - object? selection = args.GetNewValue(); - SetValue(SelectedItemProperty, selection); - } - - private void OnSecondarySelectionPropertyChanged(OverflowTemplateSettings sender, - AvaloniaPropertyChangedEventArgs args) - { - object? selection = args.GetNewValue(); - SetValue(SelectedItemProperty, selection); - } - public ITemplate ItemsPanel { get => GetValue(ItemsPanelProperty); @@ -92,6 +78,7 @@ public class Overflow : get => GetValue(TemplateSettingsProperty); set => SetValue(TemplateSettingsProperty, value); } + protected override void OnApplyTemplate(TemplateAppliedEventArgs args) { base.OnApplyTemplate(args); @@ -152,6 +139,19 @@ public class Overflow : } } + private void OnPrimarySelectionPropertyChanged(OverflowTemplateSettings sender, + AvaloniaPropertyChangedEventArgs args) + { + object? selection = args.GetNewValue(); + SetValue(SelectedItemProperty, selection); + } + + private void OnSecondarySelectionPropertyChanged(OverflowTemplateSettings sender, + AvaloniaPropertyChangedEventArgs args) + { + object? selection = args.GetNewValue(); + SetValue(SelectedItemProperty, selection); + } private void OnSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs args) { @@ -249,7 +249,7 @@ public class Overflow : return; } - double controlWidth = primaryListBox?.DesiredSize.Width ?? 0; + double controlWidth = 240; double accumulatedWidth = 0; double itemSpacing = 6;