I have made an animation in a xaml.cs file:
((Storyboard)FindResource("animate")).Begin(CurrentMatchLBLProgress);
But if I copy this and take it to the ViewModel, I get an error:
The name 'FindResource' does not exist in the current context.
How do I make this line of code work from the ViewModel?
You can access resources like below,
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
>
<Application.Resources>
<Image x:Key="ApplicationResource" Source="ApplicationResource.bmp" />
</Application.Resources>
</Application>
object resource = Application.Current.TryFindResource("ApplicationResource");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.