diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index 142c532d75..6537c470d5 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -21,6 +21,9 @@ + + + @@ -38,6 +41,9 @@ + + + diff --git a/samples/ControlCatalog/Pages/ContextFlyoutPage.axaml b/samples/ControlCatalog/Pages/ContextFlyoutPage.axaml new file mode 100644 index 0000000000..e15637aa0f --- /dev/null +++ b/samples/ControlCatalog/Pages/ContextFlyoutPage.axaml @@ -0,0 +1,102 @@ + + + + + + + Context Flyout + A right click Flyout that can be applied to any control. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/ContextFlyoutPage.axaml.cs b/samples/ControlCatalog/Pages/ContextFlyoutPage.axaml.cs new file mode 100644 index 0000000000..e64d4a2cdd --- /dev/null +++ b/samples/ControlCatalog/Pages/ContextFlyoutPage.axaml.cs @@ -0,0 +1,45 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using ControlCatalog.ViewModels; +using Avalonia.Interactivity; +namespace ControlCatalog.Pages +{ + public class ContextFlyoutPage : UserControl + { + private TextBox _textBox; + + public ContextFlyoutPage() + { + InitializeComponent(); + + var vm = new ContextFlyoutPageViewModel(); + vm.View = this; + DataContext = vm; + + _textBox = this.FindControl("TextBox"); + + var cutButton = this.FindControl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs b/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs new file mode 100644 index 0000000000..0803d178b9 --- /dev/null +++ b/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs @@ -0,0 +1,81 @@ +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Markup.Xaml; +using Avalonia.Interactivity; + +namespace ControlCatalog.Pages +{ + public class FlyoutsPage : UserControl + { + public FlyoutsPage() + { + InitializeComponent(); + + var afp = this.FindControl("AttachedFlyoutPanel"); + if (afp != null) + { + afp.DoubleTapped += Afp_DoubleTapped; + } + + SetXamlTexts(); + } + + private void Afp_DoubleTapped(object sender, RoutedEventArgs e) + { + if (sender is Panel p) + { + FlyoutBase.ShowAttachedFlyout(p); + } + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + private void SetXamlTexts() + { + var bfxt = this.FindControl("ButtonFlyoutXamlText"); + bfxt.Text = ""; + + var mfxt = this.FindControl("MenuFlyoutXamlText"); + mfxt.Text = ""; + + var afxt = this.FindControl("AttachedFlyoutXamlText"); + afxt.Text = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n\n In DoubleTapped handler:\n" + + "FlyoutBase.ShowAttachedFlyout(AttachedFlyoutPanel);"; + + var sfxt = this.FindControl("SharedFlyoutXamlText"); + sfxt.Text = "Declare a flyout in Resources:\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n\n\n" + + "Then attach the flyout where you want it:\n" + + "