mvvm - How to bind popup user control to view model and how to handle back button? (Windows Phone 8.1 Runtime) -
i'm working on wp 8.1 runtime application , i'm using caliburn.micro. application follows mvvm pattern. have itempageview , itempageviewmodel , data binding works should.
i want add popup (usercontrol) on itempageview(page) after click 1 item on itempage. popup has 1 scrollviewer containg 1 image , want :
<image x:name="imagefull" source="{binding _currentitem.imageurl}" horizontalalignment="center" verticalalignment="center"/>
_currentitem property of itempageviewmodel.
my second problem related button. i've added code:
void hardwarebuttons_backpressed(object sender, windows.phone.ui.input.backpressedeventargs e) { frame frame = window.current.content frame; if (_popupactive) { _popupactive = false; _showimagepopup.close(); frame.goforward(); //var lastpage = frame.backstack.lastordefault(); //frame.navigate(typeof(singleguideview)); e.handled = true; } else { frame.goback(); e.handled = true; } }
after click on button popup close, , after that, navigate back. "solution" stay on current view call frame.goforward(); .
about popup, can write code following in xaml (keep popup in below first grid):
<!-- first grid --> <grid> <popup x:name="mypopup" width="400"> <scrollviewer> <stackpanel> <image x:name="imagefull" source="{binding _currentitem.imageurl}" horizontalalignment="center" verticalalignment="center"/> </stackpanel> </scrollviewer> </popup> </grid>
you can handle problem popup having counter hardware button press. have @ code below:
int _popupcounter = 0, _dummycounter = 0; void hardwarebuttons_backpressed(object sender, windows.phone.ui.input.backpressedeventargs e) { _dummycounter++; frame frame = window.current.content frame; if (_popupcounter == 0 && _dummycounter == 1) { _popupcounter = 1; _popupactive = false; _showimagepopup.close(); frame.goforward(); //var lastpage = frame.backstack.lastordefault(); //frame.navigate(typeof(singleguideview)); e.handled = true; } else if (_popupcounter == 1 && _dummycounter == 2) { _popupcounter = _dummycounter = 0; frame.goback(); e.handled = true; } }
this problem related popup.
Comments
Post a Comment