mvvm-light

Is it possible to Bind the DataContext of a UserControl to a property

前提是你 提交于 2019-12-11 06:23:46
问题 I have a user control that I would like to use in two different contexts. The user control needs its DataContext set to an instance of an appropriate ViewModel that has been created by the parent view/viewmodel. I was hoping for something like: <local:Child DataContext="{Binding ChildViewModel}"/> where ChildViewModel is a inpc-styled property of the ViewModel that the page is bound to. That doesn't seem to work. Is it possible to assign the DataContext by using Binding? 回答1: It would

EventToCommand vs InputBindings Problem

时光怂恿深爱的人放手 提交于 2019-12-11 05:19:22
问题 I've created solution to reproduce a problem that I'm having with MVVM-Light EventToCommand vs InputBindings. The issue revolves around one window opening another and if I have an InputBinding connected say to the escape key and close the second view, it closes the second view and returns to the first. If I use instead the EventToCommand and then manually call the same command it closed the second view, it also closes the first. I expect it is a little hard to see without code so I've create

Choosing between bound ViewModel properties or messaging to communicate between ViewModel and View using the MVVM Light Toolkit

怎甘沉沦 提交于 2019-12-11 04:56:03
问题 I'm using MVVM Light toolkit (which I love). I currently have messaging in place for some interaction originating from the ViewModel and intended for consumption by the View. Typically these types of messages indicate the View should do something like hide itself, show a confirmation message that data was saved, etc. This works. In the constructor for the View, I register with the Messenger: Messenger.Default.Register<NotificationMessage<PaperNotification>>(this, n => HandlePaperNotification

'System.ComponentModel.INotifyPropertyChanging' in two places with MVVMLight Portable libraries

百般思念 提交于 2019-12-11 04:07:42
问题 I get this fun error when I try adding a local database to my Windows Phone 8 project. The type 'System.ComponentModel.INotifyPropertyChanging' exists in both 'e:\users\keenan\Documents\Visual Studio 2012\Projects\MAL.WindowsPhone\packages\Portable.MvvmLightLibs.4.1.27.1\lib\wp8\GalaSoft.MvvmLight.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0\System.dll' Why is System.ComponentModel.INotifyPropertyChanging in the WP8 libraries of the MVVM Portable

Unregister(this) unregisters this instance from everything?

北城余情 提交于 2019-12-11 03:38:15
问题 I am using the mvvm light toolkit for a project and I used to explicitly unregister to all the types of messages each instance was registered to, like this: Messenger.Default.Unregister<MessageType1>(this); Messenger.Default.Unregister<MessageType2>(this); ... But is this Messenger.Default.Unregister(this); giving me the same result if I want to unregister to everything ? (for example in the Cleanup method of a ViewModel) I would assume so, but I did not find any hard evidence that my

Need help setting up MVVM Light ViewModelLocator

删除回忆录丶 提交于 2019-12-11 02:29:41
问题 As the title says, I need some help setting up my ViewModelLocator. It's a Windows Phone 7 app that uses the Galasoft MVVM Light Toolkit. I have a second page in my app which I need to wire up to the view model, but after looking strenuously on the internet for the past hour, haven't really been able to find a simple example of adding ViewModels to the locator. All I need is a code example of what I need to add to the locator and whereabouts to add it. Thanks to anyone who can help me with

Silverlight + Galasoft MVVM Light + MEF loading XAP

一笑奈何 提交于 2019-12-11 02:21:42
问题 I have an application wich has some "modules" so to speak. Each user has permissions to see each module, some don't see all some see all. I want to load XAP files and load those view models(with views) in my application. How do I do that with Galasoft MVVM light and DeploymentCatalogService? Reference: http://mvvmlight.codeplex.com/ http://codebetter.com/glennblock/2010/03/08/building-hello-mef-part-iv-deploymentcatalog/ Is it even posible or am I wasting my time here? How to initialize this

WPF ListBox bind ItemsSource with MVVM-light

萝らか妹 提交于 2019-12-11 02:11:59
问题 XAML <Window x:Class="Html5Mapper.Mapper.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wpt="http://schemas.xceed.com/wpf/xaml/toolkit" Title="HTML mapper" Height="300" Width="600" > <Window.DataContext> <Binding Path="Main" Source="{StaticResource Locator}"/> </Window.DataContext> <ListBox Name="lbFiles" ItemsSource="{Binding Filescollection, Mode=OneWay}" Width="240" Height="220"> <ListBox

How to use an EventToCommand with an editable Combobox to bind TextBoxBase.TextChanged with a command?

落花浮王杯 提交于 2019-12-11 01:11:14
问题 I have an editable ComboBox. <ComboBox IsEditable="True"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <cmd:EventToCommand Command="{Binding CritereChangedCommand, Mode=OneWay}"/> </i:EventTrigger> <i:EventTrigger EventName="TextBoxBase.TextChanged"> <cmd:EventToCommand Command="{Binding CritereChangedCommand, Mode=OneWay}"/> </i:EventTrigger> </i:Interaction.Triggers> </ComboBox> I use GalaSoft.MvvmLight.Command.EventToCommand to bind the SelectionChanged event. I

Why does binding of my ObservableCollection<string> to Listbox not work?

风流意气都作罢 提交于 2019-12-11 01:04:41
问题 When I update a ObservableCollection<string> and call RaisePropertyChanged(..) somehow its content is not shown within my Listbox in WPF. I have no idea what I am doing wrong. The critical part is where I update the FileNames property: public class HistoricalDataViewRawDataViewModel : ViewModelBase { private string _currentDirectory; private ObservableCollection<string> _fileNames; private List<string> _rawData; public ICommand ChangeDirectoryCommand { get; private set; } public string