问题
I create an image-button using below code:
ImageBrush btnBrush1 = new ImageBrush(); btnBrush1.Stretch = Stretch.Uniform; btnBrush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Images/icon_LogIn.png")); btnLogIn.Background = btnBrush1;
The problem:
1) When using a mouse hovering the img-button, it turn grey background and icon disappear ( when not hovering the img-button, this image button is visible.
I want this image-button visible when hovering it or pressing it.
Thanks
回答1:
You need to set Image as Content rather than setting ImageBrush as Background.
Try this
Image img=new Image();
img.Source=new BitmapImage(new Uri("/Images/icon_LogIn.jpg",UriKind.RelativeOrAbsolute));
btnLogIn.Content = img;
来源:https://stackoverflow.com/questions/20321492/how-to-create-an-image-button