C
C#3y ago
yotabit

Color brush from App.xaml

App.xaml has a ResourceDictionary that contains a SolidColorBrush. How can I get that SolidColorBrush from a different file .cs?
// App.xaml
<Application.Resources>
<ResourceDictionary x:Name="AppResourceDic">
<Color x:Key="Colors.MyOwnBlue">#002e5e</Color>
<ResourceDictionary>
<Application.Resources>

//MyColors.cs
var color = App.AppResourceDic(Colors.MyOwnBlue); // <--- how??
// App.xaml
<Application.Resources>
<ResourceDictionary x:Name="AppResourceDic">
<Color x:Key="Colors.MyOwnBlue">#002e5e</Color>
<ResourceDictionary>
<Application.Resources>

//MyColors.cs
var color = App.AppResourceDic(Colors.MyOwnBlue); // <--- how??
2 Replies
Doombox
Doombox3y ago
var color = (Color)Application.Current.Resources["Colors.MyOwnBlue"]; should do the trick
yotabit
yotabitOP3y ago
Yes. That works. Thank you! I tried something similar, but I see my problem was that I didn't know that I could access the App as Application.Current
Want results from more Discord servers?
Add your server