windows phone 8 - How to show canvas on tapping on the image -
i have defined datatemplate in app.xaml have there image , in custom page have canvas how can show canvas on tapping on image? here datatemplate in app.xaml
<datatemplate x:key="flightinfodatatemplate"> <grid horizontalalignment="stretch" width="420"> <grid.columndefinitions> <columndefinition width="auto"/> </grid.columndefinitions> <!-- here controls, not necessary now--> <image tag="{binding id}" source="/images/bel_icon_2.png" width="20" height="20" visibility="{binding path=status, converter={staticresource statustovisibilityconverter}}" /> <!--***********--> </grid> </datatemplate>
here canvas defined in mainpage.xaml
<canvas x:name="addreminderdialog" horizontalalignment="center" height="280" width="260" verticalalignment="center" background="transparent" margin="110,178,110,238" visibility="collapsed"> <textblock foreground="yellow" text="Напомнить" horizontalalignment="center" canvas.left="78" canvas.top="28" /> <button name="btn1hourbef" borderthickness="0" background="black" content="За час" width="260" fontsize="15" height="60" margin="0,70,0,0"/> <button name="btn30minbef" borderthickness="0" background="black" content="За 30 минут" width="260" fontsize="15" height="60" margin="0,130,0,0"/> <button name="btn10minbef" borderthickness="0" background="black" content="По прилету/вылету" width="260" fontsize="15" height="60" margin="0,190,0,0"/> </canvas>
how can make visible on tapping on image?
edit - canvas meant used notification, , preferably reusable on several pages:
per comments, became clear intention of canvas provide notification message. suitable concept of dismissible popup. there system.windows.controls.primitives.popup class in framework.
example: in app.xaml:
<datatemplate x:key="flightinfodatatemplate"> ... <image tag="{binding id}" source="/images/bel_icon_2.png" width="20" height="20" visibility="{binding path=status, converter={staticresource statustovisibilityconverter}}" tap="image_tap"/> ... </datatemplate> <controltemplate x:key="addreminderdialog"> <canvas horizontalalignment="center" height="280" width="260" verticalalignment="center" background="whitesmoke" margin="110,178,110,238"> <textblock foreground="black" text="hello" horizontalalignment="center" canvas.left="78" canvas.top="28" /> <button name="btn1hourbef" borderthickness="0" background="black" content="За час" width="260" fontsize="15" height="60" margin="0,70,0,0"/> <button name="btn30minbef" borderthickness="0" background="black" content="За 30 минут" width="260" fontsize="15" height="60" margin="0,130,0,0"/> <button name="btn10minbef" borderthickness="0" background="black" content="По прилету/вылету" width="260" fontsize="15" height="60" margin="0,190,0,0"/> </canvas> </controltemplate>
in app.xaml.cs:
public partial class app : application { private popup popup = new popup(); ... private void image_tap(object sender, system.windows.input.gestureeventargs e) { var image = sender image; var modelitem = image.datacontext; const double width = 200; const double height = 100; var content = new contentcontrol(){width = width, height = height, background = new solidcolorbrush(colors.purple)}; content.template = (controltemplate) resources["addreminderdialog"]; content.datacontext = modelitem; // should define bindings in controltemplate. popup.child = content; popup.height = height; popup.width = width; popup.verticaloffset = application.current.rootvisual.rendersize.height / 2 - height / 2; popup.horizontaloffset = application.current.rootvisual.rendersize.width / 2 - width / 2; popup.isopen = true; }
Comments
Post a Comment