c# - Pinch on a textbox in WPF -


i got working code scaling frameworkelements in wpf via manipulationdelta method. works kind of elements, buttons, shapes or textblock, not textboxes.

does know how can fix it?

edit: here´s simpified version of code:

 private void canvas_manipulationdelta(object sender, manipulationdeltaeventargs  e)     {         var element = e.source frameworkelement;         var transformation = element.rendertransform matrixtransform;         var matrix = transformation == null ? matrix.identity : transformation.matrix;              matrix.scaleat(e.deltamanipulation.scale.x,            e.deltamanipulation.scale.y,             1,             1);         }          matrix.rotateat(e.deltamanipulation.rotation,                         e.manipulationorigin.x,                         e.manipulationorigin.y);          matrix.translate(e.deltamanipulation.translation.x,                          e.deltamanipulation.translation.y);          element.rendertransform = new matrixtransform(matrix);          e.handled = true;         } 

the elements created genericly, it´s same xaml:

        <canvas name="somecanvas" manipulationdelta="canvas_manipulationdelta">             <textbox   canvas.left="400" canvas.top="200" height="50" name="s3" ismanipulationenabled = "true" background="#57ff3acb"  />         </canvas> 

this because textbox handles mousedown events internally. never called, manipulation can't work. here explanation:

http://msdn.microsoft.com/es-es/library/ms750580(v=vs.85).aspx

alternatively, wrap textbox in border:

<canvas name="somecanvas" manipulationdelta="canvas_manipulationdelta">     <border canvas.left="400" canvas.top="200" background="transparent" ismanipulationenabled="true">         <textbox height="50" name="s3" background="#57ff3acb" ishittestvisible="false" />     </border> </canvas> 

put ishittestvisible property false in order let mouse events pass textbox border.

furthermore, need set border's background make hit test visible.


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -