mvvm-light

Binding CommandParameter on ItemsControl Tap event

瘦欲@ 提交于 2019-12-07 11:26:13
问题 I'm using an ItemsControl, and I want to identify which item was selected on the Tap command. My xaml is defined here: <ItemsControl ItemsSource="{Binding AllMyItems}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Tap"> <cmd:EventToCommand Command="{Binding ItemSelectedCommand}" CommandParameter="{Binding}"/> </i:EventTrigger> </i:Interaction.Triggers> .... item template .... and here is my view model: public RelayCommand<MyItem> ItemSelectedCommand { get; private set; } public

MVVMLight— Passing a parameter to a ViewModel constructor?

偶尔善良 提交于 2019-12-07 08:20:14
问题 Suppose I have a ListBox which is bound to a collection of Foo objects, and the selected Foo is displayed in a contentcontrol with the content template being a FooView . Is there a way that I can make it so that the FooView passes the selected Foo to the constructor of the FooViewModel which is it's datacontext via the ViewModelLocator ? 回答1: MainViewModel /*INotifyPropertChanged property*/ public FooViewModel CurrentFooVM{ get{/*INPC code*/} private set{/*INPC code*/} } /

MVVMLight ViewModelLocator on a UserControl

喜欢而已 提交于 2019-12-07 08:01:13
问题 Is it possible to use the MVVMLight ViewModelLocator on a UserControl. I have added it to my user control in the same way as is done on the MainWindow, but i get an error/popup in VS2010 stating "Cannot find resource named 'Locator'. Resource names are case sensitive." Has anyone tried this? Code i have thus far is pretty much a standard MVVMLight WPF starter application... UserControl <UserControl x:Class="NavTest3.PersonControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml

Implementing State handling in windows 8 using MVVM Light

喜夏-厌秋 提交于 2019-12-07 05:40:57
问题 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. 回答1: 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

Tab Bar Controller Navigation Xamarin with MVVM Light

痞子三分冷 提交于 2019-12-07 04:24:45
问题 iOS standard MVVM Light storyboard pattern is Nav -> View Controller -> Other Views But i want to use a tab bar controller as root view, up to here no one problems, but when i want to navigate from that tab view, in a new viewcontroller i lost the tab bar, and the view is load like a standard view and not like a "tabbed" view. I try to create the following schema TabBarController -> Navigation -> View -> Second View but the mvvm light pattern put the navigation controller in a SimpleIoc and i

How to handle ObservableCollection<> result from a parallelized Task in MVVM?

可紊 提交于 2019-12-07 03:46:17
问题 I am gathering data in a separate Task and I want to data bind the result to a GUI component using an ObservableCollection<> . So my code goes something like this: private ObservableCollection<MyItem> _items; public ObservableCollection<MyItem> Items { get { return _items; } set { if (_items.Equals(value)) { return; } _items = value; RaisePropertyChanged("Items"); } } private void LoadData() { Task task = Task.Factory.StartNew(() => { ObservableCollection<MyItem> itms = _htmlParser.FetchData(

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

别来无恙 提交于 2019-12-07 03:07:47
问题 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

MVVM Light and windows phone RTW any gotchas

依然范特西╮ 提交于 2019-12-07 02:08:23
Are there any gotchas using mvvm-light and the RTW windows phone 7 tools? There was a hotfix back in July but is there a new one in the pipeline? The changes between the Beta & Release version don't have any major changes comparable to those introduced in the move from CTP (Refresh) to Beta. Hopefully MVVM-Light is without impact, but it's still officially a Beta so expect a release version to come - hopefully quite soon. Of course if you find any issues as a result of the change to RTM - please share them. Barranger Ridler There's still a problem with the Template when using an actual device.

mvvm light - messaging

时间秒杀一切 提交于 2019-12-06 21:58:06
问题 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 回答1: I found the following article on the subject. The subject line seems a little unrelated but that link is for part 2 of the

Diagramming in Silverlight MVVM- connecting shapes

混江龙づ霸主 提交于 2019-12-06 15:43:48
问题 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