簡體   English   中英

如何在圖像上添加邊框?

[英]How to add a border to an image?

為什么我不能在添加的圖像上添加邊框? 此代碼有什么問題?

<Border Name="imgBorder" BorderThickness="2">
    <Image Height="150" 
     HorizontalAlignment="Left" 
     Margin="90,239,0,0" Name="image1" 
     Stretch="Fill" VerticalAlignment="Top" 
     Width="200" 
     Source="/ControlsBasics-WPF;component/GalleryImages/Lighthouse.jpg" 
     ImageFailed="image1_ImageFailed" />

</Border>

邊框顏色的默認值,也稱為BorderBrush ,為null,這意味着除非指定邊框顏色,否則您將看不到邊框。 另外,您為圖像的邊距指定了一個瘋狂的高值,這將使Image向右繪制90像素,而在實際邊框下繪制239! 黑色邊框示例

<Border Name="imgBorder" BorderThickness="2" BorderBrush="Black">
            <Image Height="150" HorizontalAlignment="Left" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="200" Source="/ControlsBasics-WPF;component/GalleryImages/Lighthouse.jpg" ImageFailed="image1_ImageFailed" />

        </Border>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM