如何在表单调整大小上调整图像大小 [英] How to resize image on form resize
问题描述
当我在运行时调整表单大小时,图像不会调整大小. 代码段如下:
<
x : 类xmlns
xmlns x
标题 =" 380" 宽度 ="610" ResizeMode ="" CanResize">
网格 > >
DockPanel x : 名称
ScrollViewer HorizontalScrollBarVisibility =" Visible" 名称 =" scrollViewer" VerticalScrollBarVisibility =可见" ="1" DockPanel.Dock =" Top" >
图片 来源 ="/TestWA1; component/Img/ASCE98MapNew. bmp" 高度 ="30959" =""55723" 边距 ="5,5,5,5" =" AP_imgMap" 拉伸 =" Fill" VerticalAlignment =" Stretch" HorizontalAlignment =" Stretch" >
Image.LayoutTransform >
TransformGroup > >
ScaleTransform ScaleX ="0.01" ScaleY =" 0.01"/>
ScaleTransform > >
ScaleTransform.ScaleX >
绑定 ElementName =" sldZoom" 路径 =" Value" 模式 ="OneWay"/>
ScaleTransform.ScaleX >
ScaleTransform.ScaleY >
绑定 ElementName =" sldZoom" 路径 =" Value" 模式 =" OneWay"/>
ScaleTransform.ScaleY >
</ScaleTransform>
</TransformGroup>
</Image.LayoutTransform>
</Image>
</ScrollViewer>
</DockPanel>
</Grid>
</Window>
Please tell me the appropraite solution to resize the image on form resize.
Hi San S,
If you set a fix size to your Image control like: "Height="30959" Width="55723" " and then it will not be resized, if you want to set dynamica size to your image, you could Bind your Image size to your Window,
Height="{Binding ElementName=myWindow, Path=ActualHeight}"
if you need return the Height after calculate, you could add a Conveter to your Binding.
最好的问候
When I resize the form on runtime, the image is not resize. The code snippet is below:
<Window x:Class="TestWA1.Image1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Image1" Height="380" Width="610" ResizeMode="CanResize">
<Grid>
<DockPanel x:Name="LayoutRoot" >
<ScrollViewer HorizontalScrollBarVisibility="Visible" Name="scrollViewer" VerticalScrollBarVisibility="Visible" Opacity="1" DockPanel.Dock="Top" >
<Image Source="/TestWA1;component/Img/ASCE98MapNew.bmp" Height="30959" Width="55723" Margin="5,5,5,5" Name="AP_imgMap" Stretch="Fill" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<Image.LayoutTransform>
<TransformGroup>
<ScaleTransform ScaleX="0.01" ScaleY="0.01"/>
<ScaleTransform>
<ScaleTransform.ScaleX>
<Binding ElementName="sldZoom" Path="Value" Mode="OneWay"/>
</ScaleTransform.ScaleX>
<ScaleTransform.ScaleY>
<Binding ElementName="sldZoom" Path="Value" Mode="OneWay"/>
</ScaleTransform.ScaleY>
</ScaleTransform>
</TransformGroup>
</Image.LayoutTransform>
</Image>
</ScrollViewer>
</DockPanel>
</Grid>
</Window>
Please tell me the appropraite solution to resize the image on form resize.
Hi San S,
If you set a fix size to your Image control like: "Height="30959" Width="55723" " and then it will not be resized, if you want to set dynamica size to your image, you could Bind your Image size to your Window,
Height="{Binding ElementName=myWindow, Path=ActualHeight}"
if you need return the Height after calculate, you could add a Conveter to your Binding.
Best regards,
这篇关于如何在表单调整大小上调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!