in XAML-CodeWie bekomme ich ForegroundAccentBrush in uwp?
Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
Wie die Farbe in C# -Code zu bekommen?
in XAML-CodeWie bekomme ich ForegroundAccentBrush in uwp?
Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
Wie die Farbe in C# -Code zu bekommen?
Farbe ändern durch C#
Anything.Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlForegroundAccentBrush"];
Alles ist Ihre Schaltfläche, Text usw. Alles, was sie unterstützen
Sie Color.FromArgb verwenden können() eine benutzerdefinierte definieren Farbe im Code:
Anything.Foreground = new SolidColorBrush(Color.FromArgb(255, 225, 48, 221));
ändern
Nur ARGB Code entsprechend Ihrer Anforderung
und mehr, wenn Sie Hex-Farbcode in Zukunft in Ihrer Anwendung wollen Sie dies tun können:
Erstellen Sie eine Methode zum Konvertieren von Hex String SolidColorBrush :
public SolidColorBrush GetSolidColorBrush(string hex)
{
hex = hex.Replace("#", string.Empty);
byte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
byte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
byte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
byte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b));
return myBrush;
}
alle Nun, die durch Aufruf der Methode links ist, um die Farbe zu bekommen und die hex-String als Parameter übergeben:
var color = GetSolidColorBrush("#FFDC3569").Color;
Danke, Mann. Sehr nützlich – Vincent
:), .............. –