如何使用自定义颜色

5 wpf

在我的wpf应用程序中,我想使用此自定义颜色代码#7EC143作为我的按钮背景....需要帮助设置按钮背景的自定义颜色代码

Ian*_*kes 7

<Button Background="#7EC143" />
Run Code Online (Sandbox Code Playgroud)


Ben*_*esh 7

在你的XAML中,只需设置如下:

<Button Name="button1" Background="#7EC143">Foo</Button>
Run Code Online (Sandbox Code Playgroud)

如果您尝试从代码中执行此操作,则更像是这样:

button1.Background = new SolidColorBrush(Color.FromArgb(0xff, 0x7e, 0xc1, 0x43));
Run Code Online (Sandbox Code Playgroud)