Viewbox and custom controls?
Posted: 13 May 2022, 23:19
Is a Viewbox unable to scale a custom control based on the Image control?
The target control is around 1200x500 and the custom control is 1280x720. The control is stretched horizontally, and shrunk vertically to fill the space. I want to maintain the aspect ratio, while filling the space with the entire image visible.
Edit:
The problem seem to be something with the grid row and column defines.
I set my rows as:
and within the center row, I set my columns as:
I get a 1085x540 center cell. Which screws up the aspect ratio.
It seems the only option is to hard code the left and right column widths.
Code: Select all
<Viewbox Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform">
<local:SceneView x:Name="SceneView" Focusable="True"/>
</Viewbox>
Edit:
The problem seem to be something with the grid row and column defines.
I set my rows as:
Code: Select all
<RowDefinition Height="1*"/>
<RowDefinition Height="540"/>
<RowDefinition Height="1*"/>Code: Select all
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="960"/>
<ColumnDefinition Width="1*"/>It seems the only option is to hard code the left and right column widths.