2015-12-17 112 views
1

我想問你,我應該做些什麼來繞過'圖像'控件的一個角落。我試過了,但它不起作用。這裏是代碼:帶圓角的圖像

EllipseGeometry elipse = new EllipseGeometry(); 
elipse.Center = new Point(16, 16); 
elipse.RadiusX = 32; 
elipse.RadiusY = 32; 
// 
// 
// 
firstSpellImage.Clip = elipse; 

其中firstSpellImage是Image類的實例。此圖像具有32x32的大小。

回答

0

您需要在邊框背景中添加圖像筆刷,並在邊框控件的任意角落四捨五入。這是如何。

<Border HorizontalAlignment="Left" Margin="0" VerticalAlignment="Bottom" Width="100" Height="100" BorderBrush="White" BorderThickness="1" 
           CacheMode="BitmapCache" CornerRadius="40,0,30,0"><!-- left-top and bottom-right round corners. --> 
     <Border.Background> 
      <ImageBrush ImageSource="https://bushrasbrilliantblog.files.wordpress.com/2014/10/placid_nature.jpg" Stretch="Fill"></ImageBrush> 
     </Border.Background> 
    </Border> 

希望這有助於

編輯寡婦電話雙贏RT 圓角圖像在C#

在這裏,你需要使用的,而不是像

Border border = new Border(); 
border.Width = 200d; 
border.Height = 200d; 
border.CornerRadius = new CornerRadius(0, 100, 0, 100); 
border.BorderBrush = new SolidColorBrush(Windows.UI.Colors.Green); 
border.BorderThickness = new Thickness(2.5d); 

ImageBrush img = new ImageBrush(); 
img.ImageSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("https://bushrasbrilliantblog.files.wordpress.com/2014/10/placid_nature.jpg", UriKind.RelativeOrAbsolute)); 
img.Stretch = Stretch.Fill; 
border.Background = img; 

LayoutRoot.Children.Add(border); 
+0

但我的ImageBrush使用C#製作了第一張圖片。 –

+0

請參閱編輯C#中的代碼 –