C# FluidMoveBehavior和导航问题(WP 8)
我将fluidmovebehavior设置为列表框:C# FluidMoveBehavior和导航问题(WP 8),c#,windows-phone-8,listbox,C#,Windows Phone 8,Listbox,我将fluidmovebehavior设置为列表框: <ItemsPanelTemplate> <StackPanel HorizontalAlignment="Stretch"> <i:Interaction.Behaviors> <ilayout:FluidMoveBehavior AppliesTo="Ch
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Stretch">
<i:Interaction.Behaviors>
<ilayout:FluidMoveBehavior AppliesTo="Children" Duration="0:0:0.3">
<ilayout:FluidMoveBehavior.EaseY>
<ExponentialEase EasingMode="EaseOut" />
</ilayout:FluidMoveBehavior.EaseY>
</ilayout:FluidMoveBehavior>
</i:Interaction.Behaviors>
</StackPanel>
</ItemsPanelTemplate>
添加:如果我设置为listbox.ItemsSource=null,则在导航到另一个页面之前,不会发生异常
我做错了什么
对不起,我的坏语言。)我找到了一个可以接受的解决方案
- 在下一页导航之前分离行为
- 从某个页面导航到上一个页面后附加行为(如果使用GoBack()方法导航)
private void ChangeBehaviorState(DependencyObject所有者,BehaviorState),其中T:DependencyObject { DependencyObject root=UIHelper.FindChildOfType(所有者); if(root==null)返回; FluidMoveBehavior b=Interaction.GetBehaviors(root)[0]作为FluidMoveBehavior; 如果(b==null)返回; 开关(状态) { 案例行为状态。附加: b、 附(根); 打破 案例行为状态。分离: b、 分离(); 打破 } }
- BehaviorState,UIHelper-用于支持的自定义类
- root-某个类列表框或另一个UIElement具有
行为
System.Windows.ni.dll!MS.Internal.XcpImports.MethodEx(System.IntPtr ptr, string name, MS.Internal.CValue[] cvData)
System.Windows.ni.dll!MS.Internal.XcpImports.MethodPack(System.IntPtr objectPtr, string methodName, object[] rawData)
System.Windows.ni.dll!MS.Internal.XcpImports.UIElement_TransformToVisual(System.Windows.UIElement element, System.Windows.UIElement visual)
System.Windows.ni.dll!System.Windows.UIElement.TransformToVisual(System.Windows.UIElement visual)
microsoft.expression.interactions.DLL!Microsoft.Expression.Interactivity.Layout.FluidMoveBehaviorBase.TranslateRect(System.Windows.Rect rect, System.Windows.FrameworkElement from, System.Windows.FrameworkElement to)
microsoft.expression.interactions.DLL!Microsoft.Expression.Interactivity.Layout.FluidMoveBehaviorBase.UpdateLayoutTransition(System.Windows.FrameworkElement child)
microsoft.expression.interactions.DLL!Microsoft.Expression.Interactivity.Layout.FluidMoveBehaviorBase.AssociatedObject_LayoutUpdated(object sender, System.EventArgs e)
System.Windows.ni.dll!System.Windows.FrameworkElement.OnLayoutUpdated(object sender, System.EventArgs e)
System.Windows.ni.dll!MS.Internal.JoltHelper.RaiseEvent(System.IntPtr target, uint eventId, System.IntPtr coreEventArgs, uint eventArgsTypeIndex)
private void ChangeBehaviorState<T>(DependencyObject owner, BehaviorState state) where T : DependencyObject
{
DependencyObject root = UIHelper.FindChildOfType<T>(owner);
if (root == null) return;
FluidMoveBehavior b = Interaction.GetBehaviors(root)[0] as FluidMoveBehavior;
if (b == null) return;
switch (state)
{
case BehaviorState.Attach:
b.Attach(root);
break;
case BehaviorState.Detach:
b.Detach();
break;
}
}