Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#7475 from wieslawsoltes/ViewboxPageXaml…
Browse files Browse the repository at this point in the history
…Only

[ControlCatalog] Set ComboBox items from xaml on ViewboxPage
  • Loading branch information
maxkatz6 authored and danwalmsley committed Feb 21, 2022
1 parent 256bba5 commit 859793b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
22 changes: 18 additions & 4 deletions samples/ControlCatalog/Pages/ViewboxPage.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:collections="clr-namespace:System.Collections;assembly=netstandard"
x:Class="ControlCatalog.Pages.ViewboxPage">

<Grid RowDefinitions="Auto,*,*">
Expand All @@ -12,8 +13,8 @@
<Border HorizontalAlignment="Center" Grid.Column="0" BorderThickness="1" BorderBrush="Orange" Width="200" Height="200">
<Border VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0" BorderThickness="1" BorderBrush="CornflowerBlue" Width="{Binding #WidthSlider.Value}" Height="{Binding #HeightSlider.Value}" >
<Viewbox
Stretch="{Binding #StretchSelector.SelectedItem}"
StretchDirection="{Binding #StretchDirectionSelector.SelectedItem}">
Stretch="{Binding #StretchSelector.SelectedItem, FallbackValue={x:Static Stretch.Uniform}}"
StretchDirection="{Binding #StretchDirectionSelector.SelectedItem, FallbackValue={x:Static StretchDirection.Both}}">
<Ellipse Width="50" Height="50" Fill="CornflowerBlue" />
</Viewbox>
</Border>
Expand All @@ -25,9 +26,22 @@
<TextBlock Text="Height" />
<Slider Minimum="10" Maximum="200" Value="100" x:Name="HeightSlider" TickFrequency="25" TickPlacement="TopLeft" />
<TextBlock Text="Stretch" />
<ComboBox x:Name="StretchSelector" HorizontalAlignment="Stretch" Margin="0,0,0,2" />
<ComboBox x:Name="StretchSelector" HorizontalAlignment="Stretch" SelectedIndex="0" Margin="0,0,0,2">
<collections:ArrayList>
<Stretch>Uniform</Stretch>
<Stretch>UniformToFill</Stretch>
<Stretch>Fill</Stretch>
<Stretch>None</Stretch>
</collections:ArrayList>
</ComboBox>
<TextBlock Text="Stretch Direction" />
<ComboBox x:Name="StretchDirectionSelector" HorizontalAlignment="Stretch" />
<ComboBox x:Name="StretchDirectionSelector" SelectedIndex="0" HorizontalAlignment="Stretch">
<collections:ArrayList>
<StretchDirection>Both</StretchDirection>
<StretchDirection>DownOnly</StretchDirection>
<StretchDirection>UpOnly</StretchDirection>
</collections:ArrayList>
</ComboBox>
</StackPanel>
</Grid>

Expand Down
19 changes: 0 additions & 19 deletions samples/ControlCatalog/Pages/ViewboxPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;

namespace ControlCatalog.Pages
{
Expand All @@ -9,24 +8,6 @@ public class ViewboxPage : UserControl
public ViewboxPage()
{
InitializeComponent();

var stretchSelector = this.FindControl<ComboBox>("StretchSelector");

stretchSelector.Items = new[]
{
Stretch.Uniform, Stretch.UniformToFill, Stretch.Fill, Stretch.None
};

stretchSelector.SelectedIndex = 0;

var stretchDirectionSelector = this.FindControl<ComboBox>("StretchDirectionSelector");

stretchDirectionSelector.Items = new[]
{
StretchDirection.Both, StretchDirection.DownOnly, StretchDirection.UpOnly
};

stretchDirectionSelector.SelectedIndex = 0;
}

private void InitializeComponent()
Expand Down

0 comments on commit 859793b

Please sign in to comment.