Viewbox and custom controls?
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.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Viewbox and custom controls?
If you want to keep the aspect ratio of a 16:9 viewbox inside a 1200x500 container, setting the Stretch to Uniform will leave margins to the left and right, and setting it to UniformToFill will fill the entire container but not all the contents (image) will be visible.
What exactly is what you want to achieve?
What exactly is what you want to achieve?
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 61 guests