I am trying to retrieve a solid color brush pre-defined in a resource dictionary (Styles.xaml) from C#.
The problem is that when i run the following code nothing happens:
private void LinkContinue_MouseEnter(object sender, MouseEventArgs e)
{
this.LinkContinue.Background = (SolidColorBrush)Resources["HoverColorBrush"];
}
However if I set the background in code explicitly it runs fine:
private void LinkContinue_MouseLeave(object sender, MouseEventArgs e)
{
this.LinkContinue.Background = new SolidColorBrush(Colors.Gray);
}
Any ideas?
So the answer was Application.Current.Resources["ResourceName"] as SolidColorBrush
! Who would've known that the Resources object points to the resource dictionary for the page? UGHHH