我有一个带有Canvas,border和Image的WPF应用程序。
<Canvas Height="300" Width="400" Background="Gray" Margin="10,210,15,150" Grid.Row="1">
<Border BorderBrush="Black" BorderThickness="2" Width="400" Height="250" Name="bord" />
<Image Name="x" Stretch="Fill" MouseWheel="x_MouseWheel" Width="359" Height="230" Grid.Row="1" Opacity="1" MouseLeftButtonDown="x_MouseLeftButtonDown" MouseMove="x_MouseMove" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="x_MouseLeftButtonUp">
<Image.Source>
<BitmapImage UriSource="/ProjectOwn;component/Images/First.png"/>
</Image.Source>
</Image>
</Canvas>
问题如下:我可以拖动图像并放大或缩小,但它不会留在我的边框/画布内,所以我可以在整个界面上移动它,同时鼠标点击它,这是不好(如果我缩小,图片也会变大,它需要整个wpf窗口)。我该如何解决?