ViewboxPage.xaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:collections="using:System.Collections"
  4. x:Class="ControlCatalog.Pages.ViewboxPage">
  5. <Grid RowDefinitions="Auto,*,*">
  6. <StackPanel Orientation="Vertical" Spacing="4">
  7. <TextBlock Classes="h2">A control used to scale single child.</TextBlock>
  8. </StackPanel>
  9. <Grid Grid.Row="1" ColumnDefinitions="*,Auto" HorizontalAlignment="Center" Margin="0,10,0,0">
  10. <Border HorizontalAlignment="Center" Grid.Column="0" BorderThickness="1" BorderBrush="Orange" Width="200" Height="200">
  11. <Border VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0" BorderThickness="1" BorderBrush="CornflowerBlue" Width="{Binding #WidthSlider.Value}" Height="{Binding #HeightSlider.Value}" >
  12. <Viewbox
  13. Stretch="{Binding #StretchSelector.SelectedItem, FallbackValue={x:Static Stretch.Uniform}}"
  14. StretchDirection="{Binding #StretchDirectionSelector.SelectedItem, FallbackValue={x:Static StretchDirection.Both}}">
  15. <Ellipse Width="50" Height="50" Fill="CornflowerBlue" />
  16. </Viewbox>
  17. </Border>
  18. </Border>
  19. <StackPanel HorizontalAlignment="Left" Orientation="Vertical" Grid.Column="1" Margin="8,0,0,0" Width="150">
  20. <TextBlock Text="Width" />
  21. <Slider Minimum="10" Maximum="200" Value="100" x:Name="WidthSlider" TickFrequency="25" TickPlacement="TopLeft" />
  22. <TextBlock Text="Height" />
  23. <Slider Minimum="10" Maximum="200" Value="100" x:Name="HeightSlider" TickFrequency="25" TickPlacement="TopLeft" />
  24. <TextBlock Text="Stretch" />
  25. <ComboBox x:Name="StretchSelector" HorizontalAlignment="Stretch" SelectedIndex="0" Margin="0,0,0,2">
  26. <collections:ArrayList>
  27. <Stretch>Uniform</Stretch>
  28. <Stretch>UniformToFill</Stretch>
  29. <Stretch>Fill</Stretch>
  30. <Stretch>None</Stretch>
  31. </collections:ArrayList>
  32. </ComboBox>
  33. <TextBlock Text="Stretch Direction" />
  34. <ComboBox x:Name="StretchDirectionSelector" SelectedIndex="0" HorizontalAlignment="Stretch">
  35. <collections:ArrayList>
  36. <StretchDirection>Both</StretchDirection>
  37. <StretchDirection>DownOnly</StretchDirection>
  38. <StretchDirection>UpOnly</StretchDirection>
  39. </collections:ArrayList>
  40. </ComboBox>
  41. </StackPanel>
  42. </Grid>
  43. </Grid>
  44. </UserControl>