如何相对缩放用户控件的大小? [英] How to relative scale size of User Control?

查看:45
本文介绍了如何相对缩放用户控件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何像图像一样相对缩放用户控件的大小(在图像编辑器中).

示例 (100%):


(来源:
(来源:stegnar.com)

好吧,我在图片编辑器中实现了这一点,但我想在 WPF 中实现.:) 我需要这个来将我的应用程序调整到不同的屏幕分辨率,同时没有隐藏(没有滚动条).

解决方案

您可以尝试放大/缩小其内容以填充可用空间的 ViewBox 控件.

<网格><Viewbox StretchDirection="Both" Stretch="Uniform"><local:UserControl1 Height="600" Width="600"/></视图框></网格>

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

Example (100%):


(source: stegnar.com)

Scaled down UC (70%):


(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).

解决方案

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>

这篇关于如何相对缩放用户控件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆