caliburn.micro

Inject EventAggregator into ViewModel with Caliburn Micro

懵懂的女人 提交于 2019-12-01 09:45:56
问题 Extracted from the Caliburn Micro documentation on EventAggregator: // Creating the EventAggregator as a singleton. public class Bootstrapper : BootstrapperBase { private readonly SimpleContainer _container = new SimpleContainer(); // ... Other Bootstrapper Config protected override void Configure(){ _container.Singleton<IEventAggregator, EventAggregator>(); } // ... Other Bootstrapper Config } // Acquiring the EventAggregator in a viewModel. public class FooViewModel { private readonly

Disposing of ViewModels in Caliburn Micro and Castle Windsor

≯℡__Kan透↙ 提交于 2019-12-01 06:06:17
I'm using Castle-Windsor as my container in a Caliburn-Micro Silverlight app. My ViewModel objects are reasonably chunky as they call WCF services and a bunch of other stuff. Therefore, when a window is closed I want to call container.Release(viewModel) so Castle can manage the whole decommission/disposal process, respecting the various lifecycles configured (as outlined in this post ). In my AppBootstrapper I have overridden GetInstance as follows: protected override object GetInstance(Type serviceType, string key) { if (string.IsNullOrEmpty(key)) return container.Resolve(serviceType); return

Disposing of ViewModels in Caliburn Micro and Castle Windsor

泪湿孤枕 提交于 2019-12-01 03:02:42
问题 I'm using Castle-Windsor as my container in a Caliburn-Micro Silverlight app. My ViewModel objects are reasonably chunky as they call WCF services and a bunch of other stuff. Therefore, when a window is closed I want to call container.Release(viewModel) so Castle can manage the whole decommission/disposal process, respecting the various lifecycles configured (as outlined in this post). In my AppBootstrapper I have overridden GetInstance as follows: protected override object GetInstance(Type

EF ComboBox not displaying SelectedItem Binding

本秂侑毒 提交于 2019-11-30 23:28:37
I am using Entity Framework and Caliburn.Micro to implement an MVVM application. Basically, I have set up AuthorModel and BookModel in a one to many relationship - an Author having multiple Books and a Book having only a single Author. I have a SelectBookWindow where I use DbContext to load ObservableCollection<Book> , from where I select a Book I want to view/edit. I then pass the selected Book as a parameter to an EditBookWindow where I have a combobox enumerating all the Authors but with the current Author selected. In here, I load up ObservableCollection<Author> using a different instance

Caliburn.Micro. Automatically call eventaggregator.Subscribe() for IHandle implementors with Autofac

纵饮孤独 提交于 2019-11-30 13:49:00
In Caliburn.Micro documentation the authors mention such possibility: documentation link IHandle inherits from a marker interface IHandle. This allows the use of casting to determine if an object instance subscribes to any events. This enables simple auto-subscribing if you integrate with an IoC container. Most IoC containers (including the SimpleContainer) provide a hook for being called when a new instance is created. Simply wire for your container’s callback, inspect the instance being created to see if it implement IHandle, and if it does, call Subscribe on the event aggregator. How is it

Different View depending on ContentControl (Caliburn.Micro)

狂风中的少年 提交于 2019-11-30 11:27:54
问题 I'm binding ViewModels to ContentControls and letting Caliburn taking care of creating and binding the view. However, I would like to customize Caliburns ViewModel->View convention based on which ContentControl I'm binding to. For example, a regular ContentControl, I want the regular View to bind (SomethingViewModel -> SomethingView). But for a certain ContentControl, I want Caliburn to fetch a View named for example SomethingViewSpecial. Is that possible? 回答1: Yes, it is possible. Use cal

Caliburn.Micro support for PasswordBox?

眉间皱痕 提交于 2019-11-30 09:24:20
The Caliburn.Micro home page at http://caliburnmicro.com makes the below claim but I am unable to make CM work with a PasswordBox control using any variation I can think of from that example. Don't see how this would work anyway since the names are not the same case. Does anyone have a CM example that does allow me to get the value of the PasswordBox? Is there a particular version of CM required? I'm running version 1.5.2 of CM. Ideally w/o using Attached Properties but if can work with CM and the only way then fine. Please no lectures on security issues as that is not an issue in my case.

One ViewModel, multiple views

孤街浪徒 提交于 2019-11-30 07:14:16
I am having a hard time getting multiple views to work against 1 viewmodel. I have read Naming Convention for Multi-View Support without getting much out of it, and have tried countless things in the process. Just to take a simple example. Say I have a ViewModel for People residing in ShellViewModel, which basically contains a list of Person-objects. I want to display them in two different ways in my application. What is the correct way to name the Views in this case, and how do I display both views in ShellView? Anders is correct, there are a number of default conventions for Caliburn.Micro ,

How can I bind key gestures in Caliburn.Micro?

让人想犯罪 __ 提交于 2019-11-30 07:06:48
How can I get Caliburn.Micro to map a key gesture to an action method on my ViewModel? For example, I want to implement a tabbed interface, and I want my ShellViewModel to have a NewTab method, which the user should to be able to invoke by pressing Ctrl+T on the keyboard. I know that the full Caliburn framework has support for gestures, but how can I do this using Caliburn.Micro? Is there perhaps some way to bind an action to a RoutedCommand (since RoutedCommands already support input gestures)? Or some other way to get gesture support? You can do it by deriving from System.Windows

WPF Context Menus in Caliburn Micro

纵饮孤独 提交于 2019-11-30 06:51:22
I'm trying to get a context menu within a ListBox ItemTemplate to call a method on the parent view model, passing in the item that was clicked on as a parameter. I have this working for other buttons in the item template, but for the context menu it seems to be failing. I have the following xaml (abbreviated for clarity): <ListBox> <ListBox.GroupStyle> <GroupStyle> ... </GroupStyle> </ListBox.GroupStyle> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ContextMenu> <ContextMenu Name="cm"> <MenuItem Header="Open" cal:Message.Attach="Open($dataContext)"> </MenuItem> </Grid.ContextMenu>