c# - Create Button in datagrid row silverlight -
i have silverlight datagrid ,
i need add 1 button in every row , if click button redirect page particular row's name value.because need show name value in redirected page.
am new silverlight application.need guidance.
chris right there lots of tutorials online gets site here example.
your datagrid
<sdk:datagrid autogeneratecolumns="false" padding="15" height="129" x:name="dgsof" width="1021" itemssource="{binding path=testlistbinding}" rowheight="30" borderbrush="#ffe4e4e4"> <sdk:datagrid.columns> <sdk:datagridtextcolumn binding="{binding path=something}" header="something"/> <sdk:datagridtemplatecolumn> <sdk:datagridtemplatecolumn.celltemplate> <datatemplate> <button margin="5" click="button_click" width="100" content="click me!"/> </datatemplate> </sdk:datagridtemplatecolumn.celltemplate> </sdk:datagridtemplatecolumn> </sdk:datagrid.columns> </sdk:datagrid>
and code behind this
private void button_click(object sender, routedeventargs e) { string clickedsomething = ((testsl.tt)(((system.windows.controls.contentpresenter)(visualtreehelper.getparent(sender button))).datacontext)).something; silverlightmessageboxlibrary.custommessage cm = new silverlightmessageboxlibrary.custommessage("you clicked on " + clickedsomething, silverlightmessageboxlibrary.custommessage.messagetype.error); cm.show(); }
this should point in right direction
Comments
Post a Comment