Sincronizar animaciones de WPF con enlace de datos

I have a zoom control from WPF Extensions toolkit that zooms in and out smoothly using an animation and pans a canvas smoothly as well. When I've bound my data to some of the controls' properties (such as Zoom and TranslateX / TranslateY) the UI is very sluggish and takes time to update.

My question is this - Is there a way to temporary disable the binding so that the animations and transitions will occur smoothly and only after they're finished my databinding will occur? I'm guessing there is such a way but I could not find out how...

¡Gracias por la ayuda, amigos!

Código:

<Controls:ZoomControl Style="{DynamicResource ZoomControlStyle1}" x:Name="zoomControl" Zoom="{Binding MapModel.ZoomFactor, Mode=OneWayToSource}" 
                      TranslateX="{Binding MapModel.CenterXLocation, Mode=OneWayToSource}" TranslateY="{Binding MapModel.CenterYLocation, Mode=OneWayToSource}">

preguntado el 08 de noviembre de 11 a las 12:11

I would say, that you don't gain a lot out of it. Binding is quite fast in wpf and i'm almost certain, that this is not your problem. Instead i would say your content in the panel is render heavy. Or you do something else expensive when setting your bound position. Are you only setting the values you are binding or is there more stuff in the background going on? -

You are correct about the content being heavy - it's a canvas loaded with many UIElement objects. When the OnPropertyChanged event handler is fired, I'm running a small function that calculates some values that are reflected in the application's UI -

1 Respuestas

Just a guess: Use a one-way binding, so that the changing of Zoom or TranslateX isn't reflected back to your binding-source.

respondido 08 nov., 11:16

Thanks for the reply, but it doesn't help. I'm currently using a OneWayToSource binding (I've added a code snippet to demonstrate) and it's still slow - Jonathan Perry

@JonathanPerry: Other way round again :-) Use OneWay en lugar de OneWayToSource. - Fischermaen

@JonathanPerry: OneWayToSource is a binding from the binding source (your control) to the binding target (your property) where the value of the target is written to the source, OneWay means a binding where the value is written from the source to the target. It means the direction of data transfer. When you choose OneWayToSource every change of the TranslateX is written back to your property during the animation. - Fischermaen

Thanks for explaining this. So I basically should update the TranslateX value only on MouseUp and not during animation? - Jonathan Perry

@JonathanPerry: You enlatado have a binding to TranlsateX, but it has to be OneWay, so the value isn't written back to your property during the animation. - Fischermaen

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.