WPF动画"不能冻结跨线程&QUOT利用这个故事板时间表树; [英] WPF Animation "Cannot freeze this Storyboard timeline tree for use across threads"

查看:1200
本文介绍了WPF动画"不能冻结跨线程&QUOT利用这个故事板时间表树;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有一个绑定到我的视图模型属性的所选项目的列表框。只要选择的项目是不是空我想在其上执行的动画。不过,我不断收到以下错误不能冻结跨线程使用这个故事板时间表树并从研究的排序明白为什么会这样。但是我不确定我需要得到我想要的行为什么办法。

 <情节提要X:键=ShowItemEdit>
    < D​​oubleAnimation是
        Storyboard.TargetName =lstItemList
        Storyboard.TargetProperty =ListBox.Width
        为了={结合ActualWidth的,的ElementName =用户控件}
        持续时间=0:0:0.40/>
    ...
< /故事板><风格X:键=ListStyle>
    < Style.Triggers>
        < D​​ataTrigger绑定={结合的SelectedItem,转换器= {StaticResource的IsNullConverter}}VALUE =FALSE>
            < D​​ataTrigger.EnterActions>
            < BeginStoryboard故事板={StaticResource的ShowItemEdit}/>
        < /DataTrigger.EnterActions>
        < / DataTrigger>
     < /Style.Triggers>
< /样式和GT;< ListBox的X:名称=lstItemList风格= {StaticResource的ListStyle}的SelectedItem ={结合的SelectedItem}>
    ...
< /列表框>


解决方案

你能张贴您的故事板?这听起来像你有一些样的故事板定义绑定的。


好了,所以,我怀疑,这是因为您使用的是故事板绑定。你不能这样做,因为WPF试图冻结所有资源由效率的杠杆模板当你使用一个<一个绑定href=\"http://msdn.microsoft.com/en-us/library/system.windows.freezable.aspx\"><$c$c>Freezable,在这种情况下,故事板,它prevents它能够被冻结。

I currently have a listbox that has its selected item bound to a property on my ViewModel. Whenever the selected item isn't null I want to perform an animation on it. However I keep getting the following error "Cannot freeze this Storyboard timeline tree for use across threads" and from research sort of understand why this is happening. However I am unsure of what approach I need to take to get the behavior I want.

<Storyboard x:Key="ShowItemEdit">
    <DoubleAnimation
        Storyboard.TargetName="lstItemList"
        Storyboard.TargetProperty="ListBox.Width"
        To="{Binding ActualWidth, ElementName=UserControl}"
        Duration="0:0:0.40" />
    ...
</Storyboard>

<Style x:Key="ListStyle">
    <Style.Triggers>
        <DataTrigger Binding="{Binding SelectedItem, Converter={StaticResource IsNullConverter}}" Value="False">
            <DataTrigger.EnterActions>
            <BeginStoryboard Storyboard="{StaticResource ShowItemEdit}" />
        </DataTrigger.EnterActions>
        </DataTrigger>
     </Style.Triggers>
</Style>

<ListBox x:Name="lstItemList" Style={StaticResource ListStyle}" SelectedItem="{Binding SelectedItem}">
    ...
</ListBox>

解决方案

Can you post your Storyboard? It sounds like you have some kind of Binding in the Storyboard definition.


Ok so, as I suspected, it's because you're using a Binding in your Storyboard. You can't do this because WPF attempts to freeze all the resources leveraged by a template for efficiency and when you use a Binding on a Freezable, in this case the Storyboard, it prevents it from being able to be frozen.

这篇关于WPF动画&QUOT;不能冻结跨线程&QUOT利用这个故事板时间表树;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆