c# - Prism PopupChildWindowAction in Desktop DLL missing -
i trying implement modal dialog in wpf prism desktop application.
from prism guidance can see proper way should using interaction:
<i:interaction.triggers> <prism:interactionrequesttrigger sourceobject="{binding confirmcancelinteractionrequest}"> <prism:popupchildwindowaction contenttemplate="{staticresource confirmwindowtemplate}"/> </prism:interactionrequesttrigger> </i:interaction.triggers>
but popupchildwindowaction
not available in microsoft.practices.prism.interactivity.dll library desktop, silverlight?
i google many different implementations of modal dialog in wpf (prism), wondering why feature missing prism desktop dll , available in silverlight dll? use interaction service interaction request suggested more appropriate approach mvvm application.
that's true exists in silverlight prism library ,
what can create own .
cs :
public class openpopupwindowaction : triggeraction<frameworkelement> { protected override void invoke(object parameter) { var popup = (childwindow)servicelocator.current.getinstance<ipopupdialogwindow>(); popup.owner = placementtarget ?? (window)servicelocator.current.getinstance<ishell>(); popup.dialogresultcommand = popupdailogresultcommand; popup.show(); } public window placementtarget { { return (window)getvalue(placementtargetproperty); } set { setvalue(placementtargetproperty, value); } } public static readonly dependencyproperty placementtargetproperty = dependencyproperty.register("placementtarget", typeof(window), typeof(openpopupwindowaction), new propertymetadata(null)); public icommand popupdailogresultcommand { { return (icommand)getvalue(popupdailogresultcommandproperty); } set { setvalue(popupdailogresultcommandproperty, value); } } public static readonly dependencyproperty popupdailogresultcommandproperty = dependencyproperty.register("popupdailogresultcommand", typeof(icommand), typeof(openpopupwindowaction), new propertymetadata(null)); }
xaml :
<i:eventtrigger sourceobject="{binding}" eventname="navigatedfrom"> <popup:openpopupwindowaction popupdailogresultcommand="{binding onnavigationconfirmed}"/> </i:eventtrigger>
and if need here code dialogwindow self .
cs:
public partial class childwindow : window, ipopupdialogwindow { public childwindow() { initializecomponent(); datacontext = this; } public new popupdialogresult dialogresult { get; set; } public system.windows.input.icommand dialogresultcommand { get; set; } }
xaml :
<window x:class="utils.actionpopupwindow.childwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" height="300" width="400" windowstartuplocation="centerowner" xmlns:popup="clr-namespace:utils.actionpopupwindow" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:name="popupwindow" > <grid> <grid.rowdefinitions> <rowdefinition height="*"/> <rowdefinition height="30"/> </grid.rowdefinitions> <textblock verticalalignment="center" horizontalalignment="center" fontsize="30"> child window <linebreak/> launched <linebreak/>main window </textblock> <stackpanel grid.row="1" background="#ffa6a6a6"> <stackpanel orientation="horizontal" horizontalalignment="right"> <button content="ok" minwidth="100" command="{binding dialogresultcommand}" commandparameter="{x:static popup:popupdialogresult.ok}" > <i:interaction.triggers> <i:eventtrigger eventname="click"> <ei:callmethodaction methodname="close" targetobject="{binding elementname=popupwindow}"/> </i:eventtrigger> </i:interaction.triggers> </button> <button content="cancel" minwidth="100" command="{binding dialogresultcommand}" commandparameter="{x:static popup:popupdialogresult.cancel}" > <i:interaction.triggers> <i:eventtrigger eventname="click"> <ei:callmethodaction methodname="close" targetobject="{binding elementname=popupwindow}"/> </i:eventtrigger> </i:interaction.triggers> </button> </stackpanel> </stackpanel> </grid>
Comments
Post a Comment