From eaa62b782824915687dcc8ddefe1746db8d06776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sun, 30 Jan 2022 13:51:19 +0100 Subject: [PATCH 1/2] Set combobox items from xaml on ViewboxPage --- samples/ControlCatalog/Pages/ViewboxPage.xaml | 21 +++++++++++++++---- .../ControlCatalog/Pages/ViewboxPage.xaml.cs | 19 ----------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/samples/ControlCatalog/Pages/ViewboxPage.xaml b/samples/ControlCatalog/Pages/ViewboxPage.xaml index 81e5046636..ac52a6d0ee 100644 --- a/samples/ControlCatalog/Pages/ViewboxPage.xaml +++ b/samples/ControlCatalog/Pages/ViewboxPage.xaml @@ -12,8 +12,8 @@ + Stretch="{Binding #StretchSelector.SelectedItem.Content, FallbackValue={x:Static Stretch.Uniform}}" + StretchDirection="{Binding #StretchDirectionSelector.SelectedItem.Content, FallbackValue={x:Static StretchDirection.Both}}"> @@ -25,9 +25,22 @@ - + + + + + + + + - + + + + + + + diff --git a/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs b/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs index 94b3f3ea14..12b5086e12 100644 --- a/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs @@ -1,6 +1,5 @@ using Avalonia.Controls; using Avalonia.Markup.Xaml; -using Avalonia.Media; namespace ControlCatalog.Pages { @@ -9,24 +8,6 @@ namespace ControlCatalog.Pages public ViewboxPage() { InitializeComponent(); - - var stretchSelector = this.FindControl("StretchSelector"); - - stretchSelector.Items = new[] - { - Stretch.Uniform, Stretch.UniformToFill, Stretch.Fill, Stretch.None - }; - - stretchSelector.SelectedIndex = 0; - - var stretchDirectionSelector = this.FindControl("StretchDirectionSelector"); - - stretchDirectionSelector.Items = new[] - { - StretchDirection.Both, StretchDirection.DownOnly, StretchDirection.UpOnly - }; - - stretchDirectionSelector.SelectedIndex = 0; } private void InitializeComponent() From 26eba8d80e16edb1ba5f269f2e38f344ff126423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sun, 30 Jan 2022 23:41:39 +0100 Subject: [PATCH 2/2] Use ArrayList for items --- samples/ControlCatalog/Pages/ViewboxPage.xaml | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/samples/ControlCatalog/Pages/ViewboxPage.xaml b/samples/ControlCatalog/Pages/ViewboxPage.xaml index ac52a6d0ee..e7e3007d35 100644 --- a/samples/ControlCatalog/Pages/ViewboxPage.xaml +++ b/samples/ControlCatalog/Pages/ViewboxPage.xaml @@ -1,5 +1,6 @@ @@ -12,8 +13,8 @@ + Stretch="{Binding #StretchSelector.SelectedItem, FallbackValue={x:Static Stretch.Uniform}}" + StretchDirection="{Binding #StretchDirectionSelector.SelectedItem, FallbackValue={x:Static StretchDirection.Both}}"> @@ -25,21 +26,21 @@ - - - - - - - - + + + Uniform + UniformToFill + Fill + None + + - - - - - - + + + Both + DownOnly + UpOnly +