how to change background color of button in UWP Apps in c# ?

后端 未结 1 1162
孤独总比滥情好
孤独总比滥情好 2021-02-19 20:01

I have a simple and I need to change colors of my buttons every second in that . I use this code btnBlue.Background = new SolidColorBrush(Windows.UI.Colors.Blue) Bu

相关标签:
1条回答
  • 2021-02-19 20:23

    You can use Color.FromArgb() to define a custom color in code:

    btnBlue.Background = new SolidColorBrush(Color.FromArgb(255, 48, 179, 221));
    

    Alternatively, you can define the color in XAML in advance as a resource:

    <Page.Resources>
        <SolidColorBrush x:Key="BlueColor" Color="#FF30B3DD" />
    </Page.Resources>
    

    You can then reference the resource from the code:

    btnBlue.Background = (SolidColorBrush)Resources["BlueColor"];
    
    0 讨论(0)
提交回复
热议问题