[英]Resizing Path element to match the dimensions of image - Silverlight
I have an image element in one xaml that is accessed and displayed on a different xaml. 我在一个xaml中有一个图像元素,该图像元素可以在另一xaml上访问和显示。 Interestingly the image automatically resizes itself to fit the grid while also maintaining the aspect ratio.
有趣的是,图像会自动调整自身大小以适合网格,同时还保持宽高比。
However I have Path elements that serve as borders to the images. 但是我有Path元素作为图像的边界。 When the Path elements are displayed they display at their normal size and I just cannot get them fit the image as borders no matter how I set the dimensions, whether it's programmatically or in xaml.
当显示Path元素时,它们以正常大小显示,而无论我如何设置尺寸(无论是以编程方式还是以xaml格式),我都无法使它们适合边框。 These Path elements are imported from an Adobe Illustrator file.
这些Path元素是从Adobe Illustrator文件导入的。
This is how the code from XAML files looks, 这就是XAML文件中代码的外观,
<ImageDisplay.xaml>
<grid>
<image name="imageToDisplay"/>
</grid>
</ImageDisplay.xaml>
<ImageBorder.xaml>
<Path Element 1>
<Path Element 2>
<Path Element 3>
<Path Element 4>
</ImageBorder.xaml>
<SubMain.xaml>
<local:ImageDisplay />
<local:ImageBorder />
<otherelements />
</SubMain.xaml>
<Main.xaml>
<SubMain.xaml />
<SubMain.xaml />
<SubMain.xaml />
</Main.xaml>
So in the Main.xaml the SubMain.xaml is allotted a certain width and height and the ImageDisplay elements re-size and fit themselves perfectly without the help of code. 因此,在Main.xaml中,为SubMain.xaml分配了一定的宽度和高度,并且ImageDisplay元素重新调整大小并完全适合自己,而无需代码的帮助。 But the same does not happen for ImageBorder element.
但是对于ImageBorder元素不会发生相同的情况。 What might I be doing wrong here?
我在这里可能做错了什么?
You can use ActualWidth
and ActualHeight
of the image after it autoresizes and set the width and height of paths. 自动调整大小并设置路径的宽度和高度后,可以使用图像的
ActualWidth
和ActualHeight
。
Image class Path class 图像类 路径类
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.