Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to relative scale size of User Control?

Tags:

How to relative scale size of User Control like image (in image editor).

Example (100%):

alt text
(source: stegnar.com)

Scaled down UC (70%):

alt text
(source: stegnar.com)

Well I achieve this in picture editor, but I would like in WPF. :) I need this to adjust my application to different screen resolution, while nothing hiding (no scrollbars).

like image 918
Peter Stegnar Avatar asked Sep 13 '09 06:09

Peter Stegnar


2 Answers

You could try the ViewBox control that scales up/down its content so that it fills the available space.

<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" Title="Window1"> <Grid>     <Viewbox StretchDirection="Both" Stretch="Uniform">         <local:UserControl1 Height="600" Width="600"/>     </Viewbox> </Grid> 

like image 141
Milan Nankov Avatar answered Sep 17 '22 05:09

Milan Nankov


you can place the whole container into a ViewBox

<Viewbox StretchDirection="Both" Stretch="Uniform">   <Grid>...</Grid> </Viewbox> 

you don't have to place each single textblock in it!

like image 32
eon Avatar answered Sep 18 '22 05:09

eon