调整Path元素的大小以匹配Silverlight的尺寸

本文关键字:Silverlight Path 元素 调整 | 更新日期: 2023-09-27 18:17:57

我在一个xaml中有一个图像元素,它被访问并显示在另一个xaml上。有趣的是,图像会自动调整大小以适应网格,同时保持长宽比。

然而,我有路径元素作为图像的边界。当Path元素显示时,它们以正常大小显示,无论我如何设置尺寸(无论是通过编程还是xaml),我都无法使它们适合图像作为边框。这些路径元素是从adobeillustrator文件中导入的。

这是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>

在Main中。xaml SubMain。xaml被分配了一定的宽度和高度,ImageDisplay元素在没有代码帮助的情况下重新调整大小并完美地适应自己。但是ImageBorder元素不会发生相同的情况。我在这里做错了什么?

调整Path元素的大小以匹配Silverlight的尺寸

您可以使用ActualWidthActualHeight的图像后,它自动调整大小和设置路径的宽度和高度。
图像类类路径