I want to use FindResource()
in C# Windows phone programming to change the style of a control, but I am not able to.
play_btn.Style = FindResource("btnplay") as Style;
This gives an error: does not exist in the current context.
If your style is defined in Resources
of the App.xaml, you have to 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 extension method: "How to implement the missing TryFindResource".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With