Answered by:
[UWP][C#]Simple Button Question

Question
-
I'm wondering how to make a button the settings Icon from Segoe MDL2 Assets, instead of a button with the settings icon inside of it as the content. Right now, I have a button that has the content set to the settings button, but the background is still a grey button when highlighted and a bit rigid as seen below.
Xaml
<Button FontFamily="Segoe MDL2 Assets" Content="" FontSize="12" Click="Button_Click" Background="{ThemeResource SystemControlAcrylicWindowBrush}" RequestedTheme="Default"/>
I'm wondering how to make the button the Settings / cogwheel itself instead of a square button with a cogwheel inside of it?
- Edited by PumpedUpKicks91 Sunday, February 18, 2018 10:25 PM Xaml added
Sunday, February 18, 2018 9:32 PM
Answers
-
Hello PumpedUpKicks91,
Anyway, try putting Style="{ThemeResource TextBlockButtonStyle}" property in the XAML instead of Background="...".
<Button FontFamily="Segoe MDL2 Assets" Content="" FontSize="12" Click="Button_Click" Style="{ThemeResource TextBlockButtonStyle}" RequestedTheme="Default"/>
- Marked as answer by PumpedUpKicks91 Sunday, February 18, 2018 11:56 PM
Sunday, February 18, 2018 11:43 PM
All replies
-
Hello PumpedUpKicks91,
Anyway, try putting Style="{ThemeResource TextBlockButtonStyle}" property in the XAML instead of Background="...".
<Button FontFamily="Segoe MDL2 Assets" Content="" FontSize="12" Click="Button_Click" Style="{ThemeResource TextBlockButtonStyle}" RequestedTheme="Default"/>
- Marked as answer by PumpedUpKicks91 Sunday, February 18, 2018 11:56 PM
Sunday, February 18, 2018 11:43 PM -
Thanks, that's what I was looking for. The color of the button (cogwheel) is now blue, but that's okay with me. I'm not sure how to customize the color/scroll-over options for the colors but If I look around enough I'll probably figure it out.Sunday, February 18, 2018 11:57 PM
-
Thank you. If you'd like to customize it further, define a Style based on the TextBlockButtonStyle.
e.g.
<Page.Resources> <Style x:Key="SophisticatedTextBlockButtonStyle" TargetType="ButtonBase"
BasedOn="{StaticResource TextBlockButtonStyle}"> <Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" /> </Style> </Page.Resources> <Button FontFamily="Segoe MDL2 Assets" Content="" FontSize="12" Click="Button_Click" Style="{StaticResource SophisticatedTextBlockButtonStyle}">If you want to alter animations, you may need to overhaul the huge ControlTemplate including a lot of VisualStates. In anyway, staring at the acutal TextBlockButtonStyle defined in generic.xaml, consider how to tackle it!
Monday, February 19, 2018 2:24 AM -
Awesome, thank you. I sincerely appreciate your time and advice. I'm saving developing the animations for last xD. As far as those go, right now I feel like Gandalf is standing in the way ("you shall not pass!"). You don't happen to have a pet balrog do ya?Wednesday, February 21, 2018 2:27 AM