2010-12-23 30 views

回答

11

只是一个边框添加到图片:

<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); 
+0

thanx的reply..but我添加图像编程包裹面板。我怎样才能以编程方式添加边框? – Shaireen 2010-12-23 10:25:07

0

内.the图像存在使用边界元素,并将其配置和背景设置为你的图像作为源图像刷。

Here's一些XAML:

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

您也可以在边界定义CornerRadius使圆角。这也将适用于图像。