![]() For an example showing how to animate an element's opacity, see Animate the Opacity of an Element or Brush. For more information about colors and brushes, see Painting with Solid Colors and Gradients Overview. You may also control the opacity of individual colors within a brush. MyOpaqueTextButton.Background = mySolidColorBrush SolidColorBrush mySolidColorBrush = new SolidColorBrush(Colors.Gray) This button's background is made 25% opaque,īutton myOpaqueTextButton = new Button() As a result, the brush's background is 25% opaque, but its contents (the button's text) remain 100% opaque. The following example sets the Opacity of a SolidColorBrush used to paint the button's Background is set to 0.25. This approach enables you to selectively alter the opacity of portions of an element, and provides performance benefits over using the element's Opacity property. MyImageButton.Content = myImageStackPanel Īnother way to control the opacity of an element is to set the opacity of the Brush that paints the element. ImageBrush myImageBrush = new ImageBrush(myBitmapImage) MyBitmapImage.UriSource = new Uri("sampleImages/berries.jpg",UriKind.Relative) (myTextBlock) īitmapImage myBitmapImage = new BitmapImage() MyTextBlock.VerticalAlignment = VerticalAlignment.Center MyImageStackPanel.Orientation = Orientation.Horizontal StackPanel myImageStackPanel = new StackPanel() The image contained within this button has an The following example sets a button's Opacity to 0.25, and the Opacity of an Image control contained with in the button to 0.5. If an element's contents have their own Opacity settings, those values are multiplied against the containing elements Opacity. Syntax: abc.clearRect (x, y, width, height) Parameters: x, y: These parameter represents the top-left coordinate of the rectangular box. MyTwentyFivePercentOpaqueButton.Content = "A Button" The clearRect () method of the Canvas 2D API which is used to erase the pixel in a rectangular area by setting the pixel color to transparent black (rgba (0, 0, 0, 0)). MyTwentyFivePercentOpaqueButton.Opacity = 0.25 MyTwentyFivePercentOpaqueButton.Opacity = new Double() Both the button and its text are made 25% opaque.īutton myTwentyFivePercentOpaqueButton = new Button() The following example sets the Opacity of a button to 0.25, making it and its contents (in this case, the button's text) 25% opaque. An element's Opacity is set to 1.0 by default. ![]() A value of 0.5 makes the element 50% opaque, and so on. A value of 0.0 makes the element completely transparent, while a value of 1.0 makes the element completely opaque. To make an element transparent or semi-transparent, you set its Opacity property. This example shows how to make a UIElement transparent or semi-transparent. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |