簡體   English   中英

c#中的圖像邊框

[英]Border around image in c#

如何在c#中的圖像周圍有黑色邊框。圖像存在於包裹面板內

只需為圖像添加邊框:

<toolkit:WrapPanel x:Name="wp">
    <Border BorderBrush="Black" BorderThickness="5" >
        <Image Source="myimage.png" />
    </Border>
</toolkit:WrapPanel>

或者在代碼中將其添加到WrapPanel:

var b = new Border
            {
                BorderBrush = new SolidColorBrush(Colors.Black),
                BorderThickness = new Thickness(5)
            };

var bi = new BitmapImage
                {
                    UriSource = new Uri("/myimage.png", UriKind.Relative)
                };

b.Child = new Image {Source = bi};

wp.Children.Add(b);

使用邊框元素並對其進行配置,並將背景設置為以圖像為源的圖像畫筆。

這是一些XAML:

    <Border BorderBrush="Black">
      <Border.Background>
        <ImageBrush ImageSource="<Your Image>"/>
      </Border.Background>
    </Border>

您還可以在邊框上定義CornerRadius以制作圓角。 這也適用於圖像。

暫無
暫無

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

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