2017-11-29 7 views
-1

私は、XAMLで画像境界でボタンを得た:UWPボタンのボーダーのイメージブラシイメージがコードの背後にありますか?

 <Button Content="Button" HorizontalAlignment="Left" Height="128" Margin="405,16,0,0" Grid.Row="1" VerticalAlignment="Top" Width="295" Foreground="Red"> 
     <Button.BorderBrush> 
      <ImageBrush Stretch="Fill" ImageSource="Assets/myGraphic.png"/> 
     </Button.BorderBrush> 
    </Button> 

の背後にあるコードのためのコードが何でありますか?

私のコード:あなたの助けのための

Button button = new Button() 
        { 
         FontWeight = FontWeights.Bold, 
         FontSize = 12, 
         --> BorderBrush = ?? // new Imagesource("Assets/myGraphic.png") 
         // Foreground = new SolidColorBrush(Colors.Red), 
         VerticalContentAlignment = VerticalAlignment.Bottom, 
         HorizontalContentAlignment = HorizontalAlignment.Center, 
         Content = "my new Button", 
         Tag = i 
        }; 

感謝!

答えて

0

BorderBrushプロパティにImageBrushを割り当てます

var button = new Button 
{ 
    BorderBrush = new ImageBrush(new BitmapImage(new Uri(...))) 
    ... 
}; 
-1

だって!

   ImageBrush test1 = new ImageBrush(); 
       test1.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/myGraphic.png")); 

       Button button = new Button() 
        { 
         FontWeight = FontWeights.Bold, 
         FontSize = 12, 
         BorderBrush = test1, 
         // Foreground = new SolidColorBrush(Colors.Red), 
         VerticalContentAlignment = VerticalAlignment.Bottom, 
         HorizontalContentAlignment = HorizontalAlignment.Center, 
         Content = "my new Button", 
         Tag = i 
        }; 
関連する問題