【发布时间】:2018-03-11 08:22:13
【问题描述】:
我想在 WPF 中创建一个像 https://codepen.io/dudleystorey/pen/HkwBo 这样的 Before/After 控件。
如何在启动时拉伸图像,而不是在分割器移动时拉伸,并使两个图像的原点相同。
<UserControl x:Class="BeforeAfterImage.BeforeAfterImageCtrl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Stretch="None" Name="Before" Grid.Column="0" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" />
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Center" />
<Image Stretch="None" Name="After" Grid.Column="2" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" />
</Grid>
【问题讨论】: