mvvm-light

How to force Cleanup() for all my ViewModels

南楼画角 提交于 2019-12-04 23:24:04
问题 My ViewModel instantiate resource that must be released when the program exits. this in all my ViewModels: public class MainViewModel : ViewModelBase { LocalServer Server { get; set; } Resource MyResorce { get; set; } public MainViewModel(LocalServer server) { this.Server = server; MyResource = new Resource(); } public override void Cleanup() { if (MyResource != null) MyResource.Close(); MyResource = null; base.Cleanup(); } } this in ViewModelLocator public class ViewModelLocator { public

Diagramming in Silverlight MVVM- connecting shapes

岁酱吖の 提交于 2019-12-04 22:37:02
have I have a quesition regarding MVVM pattern in the use case diagarm. What I have so far is a list of Items which are my Shapes. ObservableCollection<ItemsViewModels> Items; and a Collection of Connection of Items ObservableCollection<ConnectionViewModel> Each ItemViewModel has an ID and a ConnectionViewModel has two ID to connect the Items. My ItemsViewModel Collection is bound to a Itemscontrol which is layout on a Canvas. With the ElementMouseDragBehavior I am able to drag my Items around. Now comes my big question =) How can I visualize my connections that I will be able to move the

MVVM Light and EventToCommand gives Invalid Markup in VS2015

淺唱寂寞╮ 提交于 2019-12-04 21:36:29
问题 I was just about to start using VS2015 with an existing WPF project including MVVM Light toolkit but found that there is a problem with this regarding the WPF/Xaml designer. The project includes a few EventToCommand tags in markup like this: <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <command:EventToCommand Command="{Binding LoadedCommand}"></command:EventToCommand> </i:EventTrigger> </i:Interaction.Triggers> When loading xaml files using the EventToCommand construct the

XAML Heartbeat Animation - How to ensure heart beats at least twice

℡╲_俬逩灬. 提交于 2019-12-04 20:26:33
Greetings, I would like to visually show when a background process is working. This process happens at a regular intervals (say every 30 seconds), and might take 10ms or 1000ms+ to complete. I'm using MVVM-Light framework so have created a data trigger wired up to a view model property on an image of a heart fading in and out. My amateur animation technique is working when the process takes a second or more, but I would also like it to complete a full heartbeat (2 repeats) when the process takes a short period of time (<100ms), otherwise the animation is over too quickly and you can't

Can the MVVM-Light ViewModelLocator be used in nested ViewModels?

做~自己de王妃 提交于 2019-12-04 19:28:08
The Visual Studio 2008 Designer doesn't seem to like UserControls that reference the MVVM-Light ViewModelLocator. I get an error message like: Could not create an instance of type 'MyUserControl'. For example, the following XAML will cause this behavior if MyUserControl uses the ViewModelLocator to establish its DataContext. <Page x:Class="MyProject.Views.MainView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Views="clr-namespace:MyProject.Views" > <Grid> <Views:MyUserControl/> </Grid> </Page> MyUserControl is

WPF MVVM Light - Show notification before work is done

…衆ロ難τιáo~ 提交于 2019-12-04 19:03:28
In my MVVM Light application i want to show a notification before i do some some synchronous work that takes two or three seconds. I don't want the user to do anything while the work is being done so there is no need for async, Task and IProgress or backgroundworkers etc. In a ViewModel i have this code. (Note that this is not located in the code-behind of the XAML-file but in a databound ViewModel) void MyCommand(Project project) { NavigationService.AddNotification("Doin' it"); GetTheJobDone(project); ... } NavigationService adds the notification text to a databound ListView at the top of the

MVVM Light, Ninject in a mostly notification area application

[亡魂溺海] 提交于 2019-12-04 18:50:58
I need an application architecture advise. I am building a .Net 4 WPF desktop application with notification area icon support. Application has a few windows, that show up on startup, then get closed, and only the Notification Area icon remains. The notification area icon is purely WPF control that I got from this codeproject example. Since my app should remain running even when all the windows are closed, I have set a ShutdownMode="OnExplicitShutdown" in App.xaml. I will describe my idea of an architecture and startup mechanism, and you tell me where I am going wrong and correct me if possible

UWP: How to catch the click of a listview part from another listview in the viewmodel instead of code-behind?

时光毁灭记忆、已成空白 提交于 2019-12-04 18:10:01
I have this listview: <Page x:Class="DataBase.ControlsPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding CustomersViewModel, Source={StaticResource ViewModelLocator}}"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <ListView Name="HeaderList" ItemsSource="{Binding Customers}"> <ListView.ItemTemplate> <DataTemplate> <Grid> <Border Background="Bisque"> <TextBlock Text="{Binding Name"/> </Border> <ListView Name="SubItemsList" ItemsSource="{Binding Project}" ItemClick=

MVVM - WPF DataGrid - AutoGeneratingColumn Event

时光毁灭记忆、已成空白 提交于 2019-12-04 18:04:54
I'm currently taking a good look at the excellent toolkit from Laurent and I have the following question. From Blend 4, I have added an EventTrigger for the Loaded event, in my ViewModel I have the following: public RelayCommand rcAutoGeneratingColumn { get; private set; } In the constructor I have: rcAutoGeneratingColumn = new RelayCommand(o => DataGridAutoGeneratingColumn(o)); Also in the ViewModel, I have the method which I wish to be invoked by the RelayCommand: private void DataGridAutoGeneratingColumn(Object o) { DataGrid grid = (DataGrid)o; foreach (DataGridTextColumn col in grid

What is a good way to bubble up INotifyPropertyChanged events through ViewModel properties with MVVM?

孤街浪徒 提交于 2019-12-04 17:26:21
问题 I'm trying to figure out the best way to bubble up PropertyChanged events from nested Properties in my ModelView. Say I have my ModelView PersonModelView which has a Property PersonModelView.Address . Address in turn has a property City . When I bind to City in my view, I would do something like {Binding Address.City} . My problem is that even if Address implements INotifyPropertyChanged , the binding will not get updated because it is handling PropertyChanged on the PersonModelView , not