Featured post
wpf - Open new Window from view model -
hi have beginner problem. have shell (it wpf window) , in shell screen (it user control / view model).
i open new window view model, not show user control in shell.
so create new window - chatview
<window x:class="spirit.views.chatview" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:exttoolkit="clr-namespace:microsoft.windows.controls;assembly=wpftoolkit.extended" title="chatview" height="545" width="763"> <grid margin="4,4,4,4"> </grid> </window>
export chatviewmodel mef.
public interface ichatviewmodel { } [export("chatscreen",typeof(ichatviewmodel))] public class chatviewmodel { }
in view model have method:
with showscreen class me mr.marco amendola. likes this:
public class showscreen : iresult { readonly type _screentype; readonly string _name; [import] public ishellviewmodel shell { get; set; } action<object> _initializationaction = screen => { }; public showscreen initializewith<t>(t argument) { _initializationaction = screen => { var initializable = screen iinitializable<t>; if (initializable != null) initializable.initialize(argument); }; return this; } public showscreen(string name) { _name = name; } public showscreen(type screentype) { _screentype = screentype; } public void execute(actionexecutioncontext context) { var screen = !string.isnullorempty(_name) ? ioc.get<object>(_name) : ioc.getinstance(_screentype, null); _initializationaction(screen); shell.activateitem(screen); completed(this, new resultcompletioneventargs()); } public event eventhandler<resultcompletioneventargs> completed = delegate { }; public static showscreen of<t>() { return new showscreen(typeof(t)); } }
my problem if try show new window doesn’t works, works if show new user control in shell(window).
i achieve behavior in skype. have main window listbox, double clicked on item , show new chat window.
main window can publish eventaggregator on chat window , chat window can publish on main window. goal.
i know can not use class showscreen on showing new window. know correct way create new window view model , inject event aggregator vie model.
any advice? thank , time.
have looked @ windowmanager.show or windowmanager.showdialog? rob has sample @ http://caliburnmicro.codeplex.com/wikipage?title=the%20window%20manager. can inject dependency view model iwindowmanager.
- Get link
- X
- Other Apps
Comments
Post a Comment