csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
using System.Collections.Specialized;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
|
|
namespace ControlCatalog.Pages
|
|
{
|
|
public partial class CommandBarDynamicOverflowPage : UserControl
|
|
{
|
|
public CommandBarDynamicOverflowPage()
|
|
{
|
|
InitializeComponent();
|
|
((INotifyCollectionChanged)DemoBar.OverflowItems).CollectionChanged += OnOverflowChanged;
|
|
UpdateStatus();
|
|
}
|
|
|
|
private void OnWidthChanged(object? sender, Avalonia.Controls.Primitives.RangeBaseValueChangedEventArgs e)
|
|
{
|
|
if (BarContainer == null)
|
|
return;
|
|
var width = (int)WidthSlider.Value;
|
|
BarContainer.Width = width;
|
|
WidthLabel.Text = $"{width}";
|
|
}
|
|
|
|
private void OnDynamicOverflowChanged(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DemoBar == null)
|
|
return;
|
|
DemoBar.IsDynamicOverflowEnabled = DynamicOverflowCheck.IsChecked == true;
|
|
}
|
|
|
|
private void OnOverflowChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
UpdateStatus();
|
|
}
|
|
|
|
private void UpdateStatus()
|
|
{
|
|
var total = DemoBar.PrimaryCommands.Count;
|
|
var overflow = DemoBar.OverflowItems.Count;
|
|
var visible = total - overflow;
|
|
StatusText.Text = $"Showing {visible} of {total} commands, {overflow} in overflow";
|
|
}
|
|
}
|
|
}
|
|
|