c# - Animation in WPF MVVM -


i'm trying simple animation. want animate rectangle. found following code

xaml

<window x:class="wpfapplication2.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="350" width="525">     <grid>         <rectangle height="56" horizontalalignment="left" margin="204,104,0,0" name="rectangle1" stroke="black" verticalalignment="top" width="200" fill="#fffa0000" />         <button content="button" height="23" horizontalalignment="left" margin="21,276,0,0" name="button1" verticalalignment="top" width="75" click="rotate" />     </grid> </window> 

c#

private void rotate(object sender, routedeventargs e) {      doubleanimation da = new doubleanimation();      da.from = 0;      da.to = 360;      da.duration = new duration(timespan.fromseconds(3));      da.repeatbehavior = repeatbehavior.forever;      rotatetransform rt = new rotatetransform();      rectangle1.rendertransform = rt;      rt.beginanimation(rotatetransform.angleproperty, da); } 

it works perfectly, need change mvvm architecture. note element "rectangle1". how use element in mvvm?

it typically inappropriate use mvvm approach sort of thing. animation of specific ui element (almost always) view-specific code. specific single view design, , may not applicable other views bind same view model. doing in view's code behind acceptable, , best approach.


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -