How to have transparent background for button? - xaml

I am develop na UWP app, and I would like to have a transparent button. I try this (Is a simple example of my button):
<Button Name="Button"
Opacity="0">
<Image Source="/Assets/image.png"/>
</Button>
I want a button with an image, in which only the button is transparent. I've tried it that way, and by putting: Opacity="0" it puts everything transparent, and I want it to just be transparent.

Method 1
Set Opacity="0" for Button.Background. You can do it by using below code.
<Button>
<Button.Background>
<SolidColorBrush Opacity="0"/>
</Button.Background>
</Button>
Method 2
Set #00000000 as the background color of the Button. Since UWP support ARGB(Alpha RGB) color you can directly set opacity for any color in UWP app.
<Button Background="#00000000"/>

Related

Can't set InkToolbarRulerButton background as transparent using InkToolbar

I create a ink toolbar, and the initial controls are all except pens.
I can set the eraser button's background as transparent, but apply to the ruler button.
Is this a ink toolbar bug?
<InkToolbar Background="Transparent" InitialControls="AllExceptPens" TargetInkCanvas="{x:Bind inkCanvas}">
<InkToolbarEraserButton Background="Transparent"/>
<InkToolbarRulerButton Background="Transparent"/>
</InkToolbar>
The rule button is actually the InkToolbarStencilButton in the visual tree, not InkToolbarRulerButton. So that update your code snippet as follows will work.
<InkToolbar
Background="Transparent"
InitialControls="AllExceptPens"
<InkToolbarEraserButton Background="Red" />
<!--<InkToolbarRulerButton Background="Red" Foreground="Blue" />-->
<InkToolbarStencilButton Background="Red"></InkToolbarStencilButton>
</InkToolbar>

Button template is masking the clickable area of a button

I have the following UWP XAML:
<Button Content="Scan"
Command="{Binding CommandScan}" ToolTipService.ToolTip="Scan"
Style="{StaticResource ButtonIconStyle}">
<Button.Template>
<ControlTemplate TargetType="Button">
<resources:ScanIcon />
</ControlTemplate>
</Button.Template>
</Button>
ScanIcon is a user control that contains a vector image. What seems to be happening is that the icon is masking the clickable button area - that is, I can click in the drawn area of the icon only, the background of the button (whilst still within the border of the button) is not clickable.
So, my questions are: What is causing this behaviour, and how can I override it?
You can try to leave Button ControlTemplate alone and insert your image into Background of Button. I mean - you don't have to shoot big guns when you simple want to override style. If you need the Button to be exactly the shape of the image you can try DrawingBrush as described here: Painting with Images, Drawings, and Visuals

How to change color of Indeterminate ProgressBar in Windows phone

How can I change color of Indeterminate ProgressBar in Windows phone?
I have tried setting the background and border brush to null and change the foreground to black:
<ProgressBar Minimum="0" Maximum="100" IsIndeterminate="True" Foreground="Black" Background="{x:Null}" BorderBrush="{x:Null}"/>
But when I run it, it still has blue as the animation dots moving across the screen.
You need to change the <Style>
Document Outline > Right Click Progress Bar > Edit Template -> Edit A Copy
Look for
<Rectangle x:Name="E1" Fill="{ThemeResource ProgressBarIndeterminateForegroundThemeBrush}"/>
Change the Fill to any color you like
Repeat for Rectangle E2,E3,E4,E5
Or if you can just override ProgressBarIndeterminateForegroundThemeBrush
In App.xaml, like so
<Application.Resources>
<SolidColorBrush x:Key="ProgressBarIndeterminateForegroundThemeBrush" Color="Yellow" />
</Application.Resources>

Change Color of Segoe UI Font Button Windows 8

How can I change it so that any button I create for my Windows 8 app has a differently-colored Segoe UI glyph than the default (white)? I tried the following to no avail:
<Button Style="{StaticResource AppBarButtonStyle}"
AutomationProperties.Name="Button" Content="">
<Button.ContentTemplate>
<DataTemplate>
<Path Fill="red"/>
</DataTemplate>
</Button.ContentTemplate>
</Button>
My hopes were that this would create a solid red circle for a button rather than a white one, but it renders nothing at all instead. Help greatly appreciated!
Use Foreground property.
<Button Style="{StaticResource AppBarButtonStyle}" Foreground="Red"
AutomationProperties.Name="Button" Content="" />

Windows phone 8 Button style is transparent

My button looks like a text field instead of a button. Here's a screenshot:
Here's the code:
<Button FontWeight="Bold" Click="setWallpaper" Foreground="black" FontSize="35"
Margin="62,560,127,48" >Set Lockscreen</Button>
How do I fix it and make it look like a good old button?
Looks like the problem is that you have an image as your background and the button is transparent so it is showing the image. Just change your button background to White and it should fix it
<Button FontWeight="Bold" Click="setWallpaper" Foreground="Black" FontSize="35" Background="White" Margin="62,560,127,48" >Set Lockscreen</Button>