If your style is defined in Resourcesfor 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 TryFindResourceas an extension method: How to implement the missing TryFindResource file .
source
share