mvvm-light

MVVM Light Commands within an ItemsControl

会有一股神秘感。 提交于 2019-12-04 15:32:11
I'm just trying my hand at WP7 dev using the MVVM Light framework. I'm trying to fire a button command inside an ItemsControl, essentialy it's a list of cars and I'd like each element to have an edit button. The Relevant piece of the View: <ItemsControl ItemsSource="{Binding MyCars}" > <ItemsControl.ItemTemplate> <DataTemplate> <Grid x:Name="CarViewGrid"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" MinWidth="100" /> <ColumnDefinition Width="Auto" MinWidth="302"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" MinHeight="40" /> <RowDefinition Height=

Why WeakReferences in RelayCommand?

落花浮王杯 提交于 2019-12-04 15:27:24
I recently upgraded from MVVMLight 3 to 4, and noticed that my Commands broke. It turns out that the use of weak references in the new RelayCommand (implemented in version 3.5) were causing a code construct that I am using to fail. I know that there is some argument for weak refs relating to memory leak, I just don't understand it. This fails: private void InitCommand() { Command = new SwitchMainGridCommand<SwitchMainGridToolViewModel>(this).Command; } By fails, I mean that when I go to use the Command property that I had initialized and bound to, its backing methods have been garbage

Dynamically Creating Controls Following MVVM pattern

那年仲夏 提交于 2019-12-04 14:39:49
I'd like to dynamically generate some controls in my silverlight application. To be more clear, here's a simplified definition of my class: public class TestClass { [Display(Name="First Name")] public string FirstName { get; set; } [Display(Name = "Last Name")] public string LastName { get; set; } public List<CustomProperty> CustomProperties { get; set; } } Each "CustomProperty" will finally be a TextBox, CheckBox or ComboBox: public class CustomProperty { public CustomDataType DataType { get; set; } //enum:integer, string, datetime, etc public object Value { get; set; } public string

Creating a dynamic checkboxes against the list of items using mvvm light wpf?

早过忘川 提交于 2019-12-04 14:01:41
问题 I have the following scenario: I have one window say MainWindow where I am displaying the list of activities as per the specific user from the database. There is a one button present on the window. By clicking on that button a new window is getting opened having all the list of activities from the master table. Now I want add a chechbox on the second window against each item dynamically so that user can select/deselect the activities. Those selected/deselected values should save in the

How do you access the MainViewModel in ViewModelLocator from code behind?

拜拜、爱过 提交于 2019-12-04 13:17:40
问题 Building a WP7 app using MVVM light for my view models. I'm using the ViewModelLocator that gets added when you add the library through NuGet. Works great but now I need to get access to a ViewModel from code. In my code the user clicks a button and I need to search the MainViewModel (which contains several view models) and find one based on the criteria the user entered. Normally I would just response to the Click event of the button but I don't have an instance variable of the

When and where to unregister messenger with mvvmlight

拜拜、爱过 提交于 2019-12-04 12:57:38
I build a project with mvvmlight. Using Messenger send message between VMs or VM and View. Now, I wonder that when and where to unregister messenger. Could u help me? Edited: This is my scene: There are a MainWindow and a ChildWindow, the ChildWindow (include a ContentControl consist of one of two different UserControl), change the ContenControl via a SwitchButton in ChildWindow. Every window or UserControl corresponding to a ViewModel. MainViewModel sends a message to MainWindow to open the ChildWindow ; MainWindow opens the ChildWindow (firstly use UserControlView1 , don't use

MVVM Light - User Controls as Views

与世无争的帅哥 提交于 2019-12-04 12:36:36
问题 I have decided to use the MVVM Light library to help design a UI. After tons of research and trial and error, I have yet to find the answers I am looking for. I've googled and read each StackOverflow question I can find, however, my problem seems to be unique on SO. I wish to design a UI with a single window and populate it with different Views/UserControls. I do NOT want a shared navigation bar among the UserControls nor do I want multiple windows to pop-up. Each View/UserControl should bind

Button inside a WPF List view/data grid

こ雲淡風輕ζ 提交于 2019-12-04 12:18:31
I am trying to get the value/ID of the clicked row. If the row is selected, this works fine. But if I just try to click the button inside, the selected customer is null. How do I do Command Parameters here. I tried this see the answers to the following questions: ListView and Buttons inside ListView WPF - Listview with button Here is the code: <Grid> <ListView ItemsSource="{Binding Path=Customers}" SelectedItem="{Binding Path=SelectedCustomer}" Width="Auto"> <ListView.View> <GridView> <GridViewColumn Header="First Name"> <GridViewColumn.CellTemplate> <DataTemplate> <StackPanel Margin="6,2,6,2"

How to handle the back button on WP 8.1 using MVVM light?

跟風遠走 提交于 2019-12-04 12:13:36
I'm searching for the appropiate way to handle the back button pressed event on Windows Phone 8.1 WinRT using the NavigationService available on MVVM light 5. So far I think the best place to do it is inside the ViewModelLocator by registering the GoBack method of the NavigationService while creating it following the approach outlined in NavigationService in MVVM Light V5 This is an effective approach. However, I can't handle validation before navigating back so I was wondering if there is a more suitable way to handle this event. public class ViewModelLocator { public ViewModelLocator() {

WinRT MVVM Light Sample Project

穿精又带淫゛_ 提交于 2019-12-04 10:56:40
问题 If anyone starts developing Windows 8 metro applications using MVVM Light please help me to create a Windows 8 (WinRT) project template. I get bored by using Microsoft ‘s Layoutaware page(Base class). I just need to structure the class with the help of MVVM Light. If any one did this please help me or provide some links to start developing Windows 8 Metro application using MVVM Light. The major areas where i am facing issues are: Navigation (Forward and Backward) State Handling (Tombstoning