小编Sli*_*ppy的帖子

在故事板上定义并在XAML中启动的GetCurrentState

我到处搜索,似乎无法找到答案.我的应用程序生活在松散的XAML世界中,因此必须依靠XamlReaders和树木行走来寻找元素.我有一个处理这些XAML页面呈现的组件.该渲染器需要知道可以在加载的XAML上运行的故事板的状态.所以我想在渲染器中做的是这样的: -

var resources = _currentScreenFrameworkElement.Resources;
foreach (var item in resources.Values)
{
    if (item is Storyboard)
    {
        try
        {
            var storyboard = item as Storyboard;
            **if (storyboard.GetCurrentState() == ClockState.Active)**
Run Code Online (Sandbox Code Playgroud)

一切都很好.但问题是当我尝试dcheck时,它会抛出一个异常: -

"Cannot perform action because the specified Storyboard was not applied to this object for interactive control."
Run Code Online (Sandbox Code Playgroud)

环顾四周,我看到它是因为我需要让故事板可控.所以我的问题是如何在XAML中执行此操作?我没有在代码中启动故事板,因此无法将true传递给重载的BeginStoryboard.

wpf xaml storyboard

5
推荐指数
1
解决办法
2410
查看次数

标签 统计

storyboard ×1

wpf ×1

xaml ×1