Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could always port the WindowManager to WinRT in your own project. Looking at the source I don't think too much will need to change. <a href="https://caliburnmicro.codeplex.com/SourceControl/latest#src/Caliburn.Micro.Platform/net40/WindowManager.cs" rel="nofollow">https://caliburnmicro.codeplex.com/SourceControl/latest#src/Caliburn.Micro.Platform/net40/WindowManager.cs</a> </p> <p>You could bring over the Interface as well and use DI but for the sake of time here is the stand alone class. The main part for Model first binding is the <code>ViewLocator.LocateForModel</code> which returns the View from the ViewModel (aka the magic)</p> <pre><code>using System; using System.Collections.Generic; using Windows.UI.Xaml.Controls.Primitives; namespace Caliburn.Micro { public class WindowManager { public virtual void ShowPopup(object rootModel, object context = null, IDictionary&lt;string, object&gt; settings = null) { var popup = CreatePopup(rootModel, settings); var view = ViewLocator.LocateForModel(rootModel, popup, context); popup.Child = view; //popup.SetValue(View.IsGeneratedProperty, true); ViewModelBinder.Bind(rootModel, popup, null); Caliburn.Micro.Action.SetTargetWithoutContext(view, rootModel); var activatable = rootModel as IActivate; if (activatable != null) { activatable.Activate(); } var deactivator = rootModel as IDeactivate; if (deactivator != null) { popup.Closed += delegate { deactivator.Deactivate(true); }; } popup.IsOpen = true; //popup.CaptureMouse(); } protected virtual Popup CreatePopup(object rootModel, IDictionary&lt;string, object&gt; settings) { var popup = new Popup(); ApplySettings(popup, settings); return popup; } bool ApplySettings(object target, IEnumerable&lt;KeyValuePair&lt;string, object&gt;&gt; settings) { if (settings != null) { var type = target.GetType(); foreach (var pair in settings) { var propertyInfo = type.GetPropertyCaseInsensitive(pair.Key); if (propertyInfo != null) { propertyInfo.SetValue(target, pair.Value, null); } } return true; } return false; } } } </code></pre> <p>Then all you need to do is create an instance and give it a ViewModel:</p> <pre><code>var windowManager = new WindowManager(); windowManager.ShowPopup(new MyPopupThingViewModel()); </code></pre> <p>Note: I've only used this in an 8.1 app so not 100% sure if it will completely work with 8.0</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload