mvvm-light

MVVM Light Toolkit throws an System.IO.FileLoadException

一世执手 提交于 2019-12-04 05:19:47
问题 I'm running VS 2010 along with Expression Blend 4 beta. I created a MVVM Light project from the supplied templates and I get a System.IO.FileLoadException when I try to view the MainWindow.Xaml in VS 2010 designer window. The template already references System.Windows.Interactivity. Here are the details of the exception: System.IO.FileLoadException Could not load file or assembly 'System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its

Asynchronously loading Blendable sample data in MVVM Light in the view model's constructor

家住魔仙堡 提交于 2019-12-04 05:19:30
问题 I have a Windows Phone 8.1 MVVM Light project and I am struggling to keep it Blendable . As I see it I have a few options. I can load different view models depending on whether ViewModelBase.IsInDesignModeStatic is true in the ViewModelLocator constructor, or I can test ViewModelBase.IsInDesignModeStatic in the view model constructor and load data appropriately. If ViewModelBase.IsInDesignModeStatic is true I need to load data from file. Here's my code: public async Task

MVVM bind RelayCommand CanExecute to a Property?

℡╲_俬逩灬. 提交于 2019-12-04 04:02:21
问题 I have a Timer and three buttons to control it: Start, Stop, and Pause. Each button is bound to a RelayCommand. I have a TimerState property of type enum TimerState . (This is useful for setting various GUI elements.) Is there a way to somehow bind the RelayCommands' CanExecute functionality to the TimerState property? Currently, I have 3 methods that look like this: private bool CanStartTimer() { return (TimerState == TimerState.Stopped || TimerState == TimerState.Paused); } In the

WPF: MVVM: Command vs CallMethodAction?

浪子不回头ぞ 提交于 2019-12-04 03:54:43
问题 I'm learning the MVVM pattern with a new(small) project, and I've one question about the way to invoke actions on our controller: I saw many tutorial where they were telling us to use Command, implying to declare a RelayCommand, initialize it and create the action called by the RelayCommand. In the other side, I've a colleague which said me that I can use the CallMethodAction with a trigger: <i:Interaction.Triggers> <i:EventTrigger> <ei:CallMethodAction MethodName="Init" TargetObject="

MVVM ViewModel lots of properties

半世苍凉 提交于 2019-12-04 03:04:38
I am new in MVVM and I am developping an application. I have a form view with a lot of property. About 50. I can not seperate these into usercontrol because I would break the mvvm principles. I can not seperate these into model, because these contains logic. PropertyChange, Error change and these would not be poco classes, and these are not the model. Would it be nice If I kept 60 property in a same viewmodel? Do I think it wrong? How would you organize these? devdigital I can not seperate these into usercontrol because I would break the mvvm principles. I'm not sure what you mean by this.

Get selecteditem from listbox using MVVM

ε祈祈猫儿з 提交于 2019-12-03 22:15:58
I'm using MVVM in this project, I have a listbox which bind to a collection of Customers. I want to create an event to navigate a detailsPage using id of the elementselected: <ListBox ItemsSource="{Binding Customers}" x:Name="state_list" SelectionChanged="state_list_SelectionChanged"> <i:Interaction.Triggers> <i:EventTrigger EventName="selectionchanged"> <cmd:EventToCommand Command="{Binding stateSelectedCommand}" PassEventArgsToCommand="True" /> </i:EventTrigger> </i:Interaction.Triggers> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding nom}"

WPF DataGrid Validation.HasError is always false (MVVM)

无人久伴 提交于 2019-12-03 17:20:01
I have some trouble getting the Information if there are ValidationErrors inside the Datagrid / the DataGridCells. What I'm trying to do is to Disable a Button via Commands (CanExecute) basedOn the presence or absence of Validation Errors. Therefore I bind the the DataGrid's Validation.HasError to the CommandParameter on the Button. The Validation is implemented with IDataErrorInfo in the ViewModel and works just fine. Any DataGridCell containing a wrong value gets a red Border and a Tooltip describing the Error. What I just cant get to work is Binding that Button's CommandParameter to

“Resource with the name {Locator} cannot be found” Error when using mvvm-light user control

♀尐吖头ヾ 提交于 2019-12-03 17:19:23
i am using the mvvm light toolkit to create a WPF application. I created a user control and a corresponding ViewModel. I created a ViewModel property in the ViewModelLocator. I bound the user controls datacontext to the property in the Locator class. When i edit the User Control in Blend or the VS Designer everything seems to work, since i can see my design time data. When i now try to use my user control on the main window, which is created by the wpf template of the toolkit i receive the error "Resource with the name {Locator} cannot be found" and the row with my user control in the

Is MVVM dead in Windows 8 Store Apps?

可紊 提交于 2019-12-03 16:59:44
问题 I have started learning about Windows 8 Store Apps. I recall from Silverlight and WPF programming earlier that people adapted the MVVM concept and now I am not sure if I should use what i learned back then or not. I added a reference to the GalaSoft.MvvmLight and created a ViewModel and added it to my xaml as suggested by: DataContext="{Binding Source={StaticResource Locator}, Path=Welcome}" It looks like Microsoft included some kind of ModelView implementation in the LayoutAwarePage:

Managing Multiple Views/ViewModels In A Single ContentControl

人盡茶涼 提交于 2019-12-03 16:35:20
I have an application which shows a single View at a time in a ContentControl. I have a current solution, but was curious if there is a better one for memory management. My current design creates new objects when they need to be displayed, and destroys them when they are no longer visible. I'm curious if this is the better approach, or maintaining references to each view and swapping between those references is better? Here is a little more explanation of my application layout: A very simplified version of my MainWindow.xaml looks like this: <Window ... > <Window.Resources> <DataTemplate