c# - Popup control on Datagrid -


i'm having 2 issues here. have datagrid populated items. want happen display popup control under datagrid selected row. here's have:

<grid>     <datagrid canuserreordercolumns="false"                canusersortcolumns="false"                headersvisibility="none"                autogeneratecolumns="false"                verticalalignment="stretch"                itemssource="{binding itemcollection}"                selecteditem="{binding selecteditem}">         <datagrid.columns>             <datagridtextcolumn width="*" binding="{binding path=key}" />             <datagridtextcolumn width="*" binding="{binding path=value}" />         </datagrid.columns>     </datagrid>      <popup popupanimation="scroll" placement="bottom" allowstransparency="true" isopen="{binding popupvisible}" margin="0" staysopen="true" >         <local:popupcontrol />     </popup> </grid> 

i set isopen property in viewmodel when selecteditem changed so:

popupvisible = true; 

with code able show popover.

first issue: staysopen = "true" popup not move when window moved. way handle button control change staysopen "false" popup dismissed when clicking somewhere else in window. when datagrid control popup doesn't show @ when selecteditem changed. why this?

second issue: how popup display under selected row?

this solution worked me:

first issue: when open popup initially, save window co-ordinates.

point coordinate = mainwindow.pointfromscreen(new point(0,0)); xsavedwindowpos = coordinate.x; ysavedwindowpos = coordinate.y; 

in locationchanged event handler of mainwindow: set popup offsets , save new window position.

point currentpos = (sender window).pointfromscreen(new point(0,0)); yourpopup.horizontaloffset += (xsavedwindowpos - currentpos.x); yourpopup.verticaloffset += (ysavedwindowpos - currentpos.y); xsavedwindowpos = currentpos.x; ysavedwindowpos = currentpos.y; 

second issue: open popup in "cellmouseclick" event handler of datagrid. can set staysopen too.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -