How to show a popup on datagrid button click in wpf c#? -
i have common popup in wpf window , have button in datagrid well. want open popup when button clicked. popup should independent each button click. example, let's have 2 rows in datagrid. when click on first button popup should appear,then changes popup , close it. click second button should open new popup instead of changes made before. i'm using common popup this. please tell me possible handle requirement common popup window?
xaml
<popup x:name="popupserver" isopen="false" placement="mousepoint" > <border background="#ffeff2f3" borderbrush="black" borderthickness="1" width="229" height="145"> <stackpanel orientation="horizontal" margin="0,0,0,-17"> <grid width="227" margin="0,0,0,10"> <groupbox header="configuration" horizontalalignment="left" margin="9,6,-9,0" verticalalignment="top" height="125" width="211"> <grid> <label content="auto restart" horizontalalignment="left" margin="10,6,0,0" verticalalignment="top"/> <toggleswitch:horizontaltoggleswitch x:name="tsautorestart" horizontalalignment="left" margin="97,10,0,0" verticalalignment="top" width="46" thumbsize="22" height="21" rendertransformorigin="3.522,1.048"> <toggleswitch:horizontaltoggleswitch.uncheckedbackground> <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0"> <gradientstop color="#ffc80000" offset="1"/> <gradientstop color="#ff0a0a0a" offset="0.853"/> </lineargradientbrush> </toggleswitch:horizontaltoggleswitch.uncheckedbackground> <toggleswitch:horizontaltoggleswitch.checkedbackground> <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0"> <gradientstop color="#000000" /> <gradientstop color="#000000" offset="1" /> </lineargradientbrush> </toggleswitch:horizontaltoggleswitch.checkedbackground> <toggleswitch:horizontaltoggleswitch.thumbbrush> <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0"> <gradientstop color="#ffd6d4d4" /> <gradientstop color="#ffd6d4d4" offset="1" /> <gradientstop color="#ffd6d4d4" offset="0.02" /> </lineargradientbrush> </toggleswitch:horizontaltoggleswitch.thumbbrush> </toggleswitch:horizontaltoggleswitch> <combobox x:name="cbduration" horizontalalignment="left" verticalalignment="top" width="92" margin="97,40,0,0"> <comboboxitem content="30 minutes"/> <comboboxitem content="1 hours"/> <comboboxitem content="2 hours"/> </combobox> <label content="after" horizontalalignment="left" verticalalignment="top" width="83" margin="9,36,0,0"/> <button x:name="btnapply" content="apply" horizontalalignment="left" margin="125,75,0,0" verticalalignment="top" width="64" click="btnapply_click"/> </grid> </groupbox> </grid> </stackpanel> </border> </popup>
datagrid
<datagridtemplatecolumn> <datagridtemplatecolumn.celltemplate> <datatemplate> <stackpanel> <button x:name="txtserverinfo" click="txtserverinfo_click" height="23" width="28"> <button.background> <imagebrush imagesource="img.png"/> </button.background> </button> </stackpanel> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn>
code behind file
private void txtserverinfo_click(object sender, routedeventargs e) { popupserver.isopen = true; }
if want use common popup means better create popup in separate user control.then button click can create new object user control , open popup using user controls object.then values inside popup independent of previous button click.
Comments
Post a Comment