c#中的图像边框

Sha*_*een 6 c# visual-studio-2010 windows-phone-7

如何在c#中的图像周围有黑色边框.图像存在于包裹面板内

Mat*_*cey 11

只需为图像添加边框:

<toolkit:WrapPanel x:Name="wp">
    <Border BorderBrush="Black" BorderThickness="5" >
        <Image Source="myimage.png" />
    </Border>
</toolkit:WrapPanel>
Run Code Online (Sandbox Code Playgroud)

或者在代码中将其添加到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);
Run Code Online (Sandbox Code Playgroud)