我可以知道如何使图像适合设计的边框吗?
下面是我完成的代码。
<Border Grid.Row="1" BorderThickness="1" BorderBrush="LightGreen" Margin="20" CornerRadius="30">
<Border.Background>
<LinearGradientBrush EndPoint="0.504,1.5" StartPoint="0.504,0.03">
<GradientStop Color="#F9FFF0" Offset="0"/>
<GradientStop Color="#F3FFE2" Offset="0.567"/>
</LinearGradientBrush>
</Border.Background>
<Image Source="/LBKIOSK;component/Resources/Images/Background/klhoho.jpg" Opacity="0.3" Stretch="UniformToFill"/>
<Border.Effect>
<DropShadowEffect ShadowDepth="5" Color="#599204"></DropShadowEffect>
</Border.Effect>
</Border>
但输出显示如下,图像不适合边框
答案 0 :(得分:1)
可以将<Border.Background/>
属性设置为<ImageBrush/>
,例如:
<Border Grid.Row="1" BorderThickness="1" BorderBrush="LightGreen" Margin="20" CornerRadius="30">
<Border.Background>
<ImageBrush Stretch="UniformToFill" ImageSource="/LBKIOSK;component/Resources/Images/Background/klhoho.jpg"/>
</Border.Background>
<Border.Effect>
<DropShadowEffect ShadowDepth="5" Color="#599204"></DropShadowEffect>
</Border.Effect>
</Border>