mvvm-light

MVVM-Light Locator Pattern and Reusable UserControl

余生颓废 提交于 2020-02-25 13:44:57
问题 I have an existing Silverlight 4 application that I am attempting to convert to use the locator pattern and the MVVM-Light library. My understanding is that the MvvmLocator class keeps a reference to each view model and allows you to bind the DataContext of each view to an appropriate ViewModel in the locator. My application uses a navigation frame and hence each page in the app is a UserControl that gets loaded into the Content frame. I can see how easy it is to bind each page view to the

Creating a new instance of an object each time method is called

主宰稳场 提交于 2020-02-13 22:24:19
问题 Messenger.Default.Register<OpenWindowMessage>(this, message => { var adventurerWindowVM = SimpleIoc.Default.GetInstance<AdventurerViewModel>(); adventurerWindowVM.Adv = message.Argument; var adventurerWindow = new AdventurerView() { DataContext = adventurerWindowVM }; adventurerWindow.Show(); }); This code is fairly simple; it just opens a new window and sets the DataContext of the new window. The problem I'm having is that if I execute this twice, the content of the first instance will be

Xamarin.Forms MVVM Light IDialogService ShowMessage throwing native exception

↘锁芯ラ 提交于 2020-02-04 11:01:20
问题 i recently started working with MVVM Light and just used the IDialogService for the first time. My ViewModelLocator ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); // Register the dialog service provided by mvvm light SimpleIoc.Default.Register<IDialogService, DialogService>(); My ViewModel private IRestService _restService; public OrderViewModel (IDialogService dialogService ) { _dialogService = dialogService; } And finally using ShowMessage: await _dialogService.ShowMessage(

WPF ComboBox Selected Item with reference to an object

对着背影说爱祢 提交于 2020-01-25 07:15:09
问题 I'm trying to define a selected item in a combobox. It working fine if I'm just using a String to declare the selected item but not if using an object. <ComboBox HorizontalAlignment="Left" VerticalAlignment="Top" Width="81" materialDesign:HintAssist.Hint="Woche" Margin="10" ItemsSource="{Binding weekSelection}" DisplayMemberPath="name" SelectedItem="{Binding nodeWeek, Mode=TwoWay}" SelectedValue="name" /> - private week _nodeWeek; public week nodeWeek { get { return _nodeWeek; } set {

SimpleIoc - can it provide new instance each time required?

半腔热情 提交于 2020-01-19 01:31:46
问题 So far as I understand, SimpleIoc uses GetInstance method to retrieve an instance of a class that is registered. If the instance doesnt exist, it will create it. However, this instance is cached and always retrieved, which mimics the singleton pattern. My thinking is that there is no need to keep an instance of ViewModel in a memory if there is a small possibility that this ViewModel will be needed twice, so I would like to create new instance of it each time that is needed. If we have are

Crystal Reports MVVM Data Source

这一生的挚爱 提交于 2020-01-15 12:49:07
问题 I have an MVVM application and would like to add Crystal Reports. I have a ViewModel of PatientList and would Like to Bind the Report to an Observable collection of Patients in the ViewModel. the Collection is not appearing in the data sources window. 回答1: I guess you are refering to Crystal-Reports datasource window right? If so - I think you will never find the ObservableCollection there (and I don't know if you can have CR observe the collection) but on the document-class in Crystal-Report

RelayCommand with Argument throwing MethodAccessException

谁说胖子不能爱 提交于 2020-01-14 13:35:12
问题 I am creating an application using .Net and MVVM Light and I am having some trouble for RelayCommands. I'm trying to create a RelayCommand which takes in a single argument and passes it to a function within the same ViewModel. However everytime I try and do this I keep getting the following exception: A first chance exception of type 'System.MethodAccessException' occurred in mscorlib.dll My code is below. XAML <TextBlock Style="{StaticResource QueryFormTab}" > <Hyperlink Command="{Binding

MVVM Light - PCL+WPF - Getting exception of type Microsoft.Practices.ServiceLocation.ActivationException

我怕爱的太早我们不能终老 提交于 2020-01-14 08:17:09
问题 Background Hi all SO viewers. I am normally an Android developer, but now I'm developing a cross platform application targeting WPF and Android. That being said, there's practically no info on how to directly do what I want. So, I ended up finding a 3-part blog series that goes in depth on how to develop a Windows-based cross platform MVVM project. As long as I set the PCL to be compatible with Xamarin.Android, any code that doesn't throw an error SHOULD work once I get to the Android side of

“Unable to determine application identity of the caller” for ViewModelLocator

馋奶兔 提交于 2020-01-14 06:42:52
问题 In app.xaml, i have an error while defining ViewModelLocator. App launches and runs fine, but it annoys me in Studio. Wondering, what can be a reason. Highlighted line is <vm:ViewModelLocator x:Key="ViewModelLocator" d:IsDataSource="True"/> Error: Error 1 Unable to determine application identity of the caller. If to get inside of vm:ViewModelLocator, there's no sign of errors there. Should i re-check all my viewmodels and add IsoStorage designtime protection? if (!System.ComponentModel

“Unable to determine application identity of the caller” for ViewModelLocator

和自甴很熟 提交于 2020-01-14 06:42:11
问题 In app.xaml, i have an error while defining ViewModelLocator. App launches and runs fine, but it annoys me in Studio. Wondering, what can be a reason. Highlighted line is <vm:ViewModelLocator x:Key="ViewModelLocator" d:IsDataSource="True"/> Error: Error 1 Unable to determine application identity of the caller. If to get inside of vm:ViewModelLocator, there's no sign of errors there. Should i re-check all my viewmodels and add IsoStorage designtime protection? if (!System.ComponentModel