mvvm-light

MvvmLight EventToCommand and WPFToolkit DataGrid double-click

笑着哭i 提交于 2019-12-05 10:55:00
Trying to figure out how to use EventToCommand to set a datagrid double click handler for rows. The command lives in the viewmodel for each row. Just that much out of my experience, since I haven't used interactions yet. Thanks. I would have used mvvmlight tag, but I don't have high enough rep yet to make new tags. This would be the solution if the Command lives on the "GridVieModel" and not on the "RowViewModel". <Window... ...xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns

Implementing State handling in windows 8 using MVVM Light

限于喜欢 提交于 2019-12-05 08:27:51
How i can implement state handling (running / resume / Terminate states ) using mvvm light. The major issue i a facing is with Navigation. I am totally uncontrolled with the navigation stack. How i can effectively manage this with MVVM Light. You might be interested in the open source Okra App Framework that is freely available on CodePlex and NuGet (disclaimer: I am the lead developer on this project). This has been designed from the ground up for Windows 8 applications, in particular those that use the MVVM pattern (and you can still use the MVVM Light base classes to define your view-models

Global static resources in a WPF class library?

孤街浪徒 提交于 2019-12-05 08:08:05
In a WPF application, you can put your global static resources in app.xaml .. like <Application.Resources> <!--Global View Model Locator--> <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> </Application.Resources> That was from MVVM Light ;). Now, if your project is a wpf class library, what is a proper way to initialize such global static resources? You can create a ResourceDictionary with your resources and merge the dictionaries using your code as below. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:vm="clr-namespace:WPFProject

Errors in App.xaml trying to use MVVM Light in Windows Phone 8 project

橙三吉。 提交于 2019-12-05 07:26:39
When I add the MVVM Light package via NuGet I get errors referencing the lines in the App.xaml file added during the install. These errors only appear in Windows Phone 8 projects. The exact same lines in a Windows Phone 7 project do not raise any errors. The MVVM Light added lines are: <ResourceDictionary> <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> <ResourceDictionary.MergedDictionaries></ResourceDictionary.MergedDictionaries> </ResourceDictionary> These lines are positioned just before the ending </Application.Resources> tag. The errors reported in the Error List pane are:

Handling user settings with MVVM

心不动则不痛 提交于 2019-12-05 06:33:39
Currently i'm developing an WPF application with the MVVM-light framework. On this moment i'm setting my settings as shown in the next example code in my viewmodel: private string _property public string Property { get { return _property; } set { if (_property != value) { _property = value; Settings.Default.Property = value; RaisePropertyChanged("Property"); } } } I save my settings on application exit: protected override void OnExit(ExitEventArgs e) { Settings.Default.Save(); } Everything works as intended, but ... Question: Is this a correct approach or is there a better way of handling

EventToCommand for Loaded event not working as expected if Window.SizeToContent = WidthAndHeight

人走茶凉 提交于 2019-12-05 04:39:05
I find out that the EventToCommand for the Loaded-event is not working as expected if the Window.SizeToContent attribute is set to WidthAndHeight . The Loaded-event seems to be fired correctly, but the EventToCommand.Command property is bound AFTER the Loaded event is fired. If SizeToContent is Manual the Command will be bound BEFORE Loaded is fired and it works as expected. Does anyone also have problems with this behavior and/or an explanation for this? My workaround for now is to bind to the DataContext of the window: <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded" > <command

Get selecteditem from listbox using MVVM

狂风中的少年 提交于 2019-12-05 04:38:31
问题 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>

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

为君一笑 提交于 2019-12-05 04:19:45
问题 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

WPF DataGrid Validation.HasError is always false (MVVM)

a 夏天 提交于 2019-12-05 01:49:51
问题 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

mvvm light - messaging

徘徊边缘 提交于 2019-12-05 01:29:49
I'm curently teaching myself the MVVM pattern. I've hit my first snag with the concept of messaging. I know messaging is contained in the mvvm-light toolkit. But I cannot find an example of usage anywhere (no sample projects are provided in the download). If anyone can direct me to some information as to how to use messaging in that toolkit, that would be ace. Thanks I found the following article on the subject. The subject line seems a little unrelated but that link is for part 2 of the article and if you read and scroll down a bit you will find info on the RelayCommand, Messenger,