If your style is defined in Resources
for App.xaml, you should use:
play_btn.Style = App.Current.Resources["btnplay"] as Style;
otherwise (e.g. MainPage.xaml, SecondPage.xaml ...):
play_btn.Style = this.Resources["btnplay"] as Style;
Or you can implement TryFindResource
as an extension method: How to implement the missing TryFindResource file .
source
share