嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
在背景图上写控件时,控制所写控件的相对布局不变,WPF 控件的相对布局
启动:
未按等比例设置的放大效果,可以看出我们事先绘制的红色框线已经偏离原先在内的Button
按等比例缩放效果:
可以看出,等比例缩放效果,是一直红色框线和Butong的位置保持相对不变
未按等比例缩放
<Window x:Class="WpfApp1.Window3"
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:WpfApp1"
mc:Ignorable="d"
Title="Window3" Height="350" Width="560" WindowStyle="None" ResizeMode="NoResize">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="bg.png"/>
</Grid.Background>
<Button Content="Button" HorizontalAlignment="Left" Margin="402,249,0,0" VerticalAlignment="Top" Width="62" RenderTransformOrigin="0.471,0.289" Height="24"/>
<Button Content="最大化" Click="Button_Click" HorizontalAlignment="Left" Margin="87,142,0,0" VerticalAlignment="Top" Width="75"/>
<Button Content="等比例缩放窗口" Click="Button_Click_1" HorizontalAlignment="Left" Margin="87,221,0,0" VerticalAlignment="Top" Width="104" Height="29"/>
</Grid>
</Window>
等比例缩放:
<Window x:Class="WpfApp1.Window4"
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:WpfApp1"
mc:Ignorable="d"
Title="Window3" Height="350" Width="560" WindowStyle="None" ResizeMode="NoResize">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="bg.png"/>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="450*"></ColumnDefinition>
<ColumnDefinition Width="80*"></ColumnDefinition>
<ColumnDefinition Width="100*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="760*"></RowDefinition>
<RowDefinition Height="100*"></RowDefinition>
<RowDefinition Height="230*"></RowDefinition>
</Grid.RowDefinitions>
<Button Content="Button" Grid.Column="1" Grid.Row="1" Margin="5"/>
<Button Content="最大化" Click="Button_Click" HorizontalAlignment="Left" Margin="87,142,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
</Window>