wpf - Extend Width In Both Directions -


i'm trying animate box width extend in both left , right direction. of course it's extending in right direction, how have extend in both. wpf codes in c# can't find answer google.

imports system.windows.media.animation  class mainwindow     private sub enlargebtn_click(sender object, e routedeventargs) handles enlargebtn.click          dim newwidth = 300         dim widthanimation new doubleanimation(newwidth, timespan.frommilliseconds(1000))         box.beginanimation(widthproperty, widthanimation)     end sub end class 

you need animate left position width.

if can change left position you'll need change width twice amount you're changing left property box grow uniformly in both directions.

if can't change left or x property of rectangle (because doesn't appear have 1 can access - msdn) solution might put inside container (a grid or border) , set it's horizontalalignment center.


Comments