在设计WPF界面时,我们想让页面做到自适应布局时,就需要用到Viewbox控件来编写页面。
viewBox属性允许您将给定的一组图形拉伸以适应特定的容器元素。
代码:
<Window x:Class="wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:wpf"
mc:Ignorable="d" Height="Auto" Width="Auto" MinHeight="200" MinWidth="400">
<Window.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">