mvvm

Binding ListBoxItem.ItemSelected to the bound item in Silverlight

I am using MVVM pattern with Silverlight 4 to bind a collection of TODO items to a ListBox. There is a property IsSelected on each TODO entity. This allow for multiple selections to be made in the UI that are bound back to the ViewModel. At the same time any changes made by the ViewModel get reflected in the View. I am basically trying...

mvvm light PassEventArgsToCommand break app in ListBoxDragDropTarget

Hi I'm trying to pass eventargs to comman that I bind in ViewModel. Everything works fine if I don't use PassEventArgsToCommand="True". But If put PassEventArgsToCommand="True" than app break. Did you have similar problem? <Controls:ListBoxDragDropTarget Grid.Column="1" AllowDrop="true" HorizontalContentAlignment="Stretc...

Binding to properties outside of the datacontext

Hey all, I am creating a wpf application and am having a little difficulty implementing an user interface idea I have. I have a MasterViewModel bound to the MainWindow which exposes an observable collection of ViewModels. I have written some commands that essentially switch the current view model in the observable collection and this s...

Wpf UserControl and MVVM

I am thinking about writing a WPF User Control for my application. I am using MVVM in my application. User control's may require Dependency Properties that can be set my Parent View. when using MVVM, the idea is that the Parent View will eventually create a binding between the UserControls DP with Parent View's VM) Dependency Properti...

WPF Prism Updating ViewModel

Hi, I am new to Prism WPF world, have one simple question. I have registered my view and viewmodel in the module initialise method like below var navigatorView = new NavigationMenu.View.NavigationBarView(); navigatorView.DataContext = m_Container.Resolve<NavigationMenuViewModel>(); var regionManager = m_Contain...

Prism, Regions, Magic strings and refactoring : am I missing something here ?

Hello, chaps. To build a composite application view in my application, with different regions, untill now, I've always used content presenter and used DataBinding to set its content. If I wanted to change its content, I would just have to use an event aggregator, publish a ViewZoneChangedEvent, subscribe to it in the "shell" window, an...

Handle Database Transactions & Exceptions in TreeView with Multi-Tier MVVM

Hello: Background: I have a custom user control based around a WPF TreeView. I've been using the MVVM pattern and have a base view model TreeNode class and several derived view models such as LocationNode, LocationFolder, PersonNode, PersonFolder, CollectionNode, CollectionFolder, etc.. A example of how the tree might be laid out is: ...

What is the real advantage of keeping code out of the XAML code behind?

There is a lot of effort in the Silverlight community to keep a XAML's code behind file as free of code as possible. What is the real motivation behind this? For example, what is the advantage of using a command instead of an event handler? If I have <Button x:Name="SaveButton" Content="Save" Click="SaveButton_Click" /> ... private...

MVVM and DI - How to handle Model objects?

I'm using Caliburn and C#, but I feel like this is a generic MVVM/DI question. Let's say I have a view model, NoteViewModel, that is passed a model object called Note. Here is some code: class NoteViewModel : PropertyChangedBase { private readonly Note _note; public NoteViewModel(Note note) { _note = note; } public str...

Satisfying Child View Model Dependencies

Hello, I'm building a master-detail form. The master view model constructs instances of the details view model. These details view models have several dependencies which need to be satisfied with new class instances. (This is because they need service layers that operate in a separate data context from the master vm.) What would be the...

WPF/MVVM: Weird behaviour of wpf buttons with Commands disabling

Hello, just some code...: Question is at bottom. XAML: <StackPanel Orientation="Horizontal"> <Button Content="Start" Command="{Binding FirstDateCommand}" /> <Button Content="Back" Command="{Binding PreviousDateCommand}" /> <DatePicker SelectedDate="{Binding SelectedDate}" DisplayDateStart="{Binding...

WCF RIA, Silverlight 4

I am working on a Silverlight 4 project. I am using WCF RIA on the server and expose the model using a DomainService. I have 2 tables, let's say Table1 and Table2 linked with Foreign key say FID. Therefore, i can Load data from both table 1 and table 2 in single data grid. But my question is while editing datagrid if i need to change ...

MVVM DESIGN PATTERN

Hi All, Am very much new to this MVVM DESIGN PATTERN.Am doing a small project in this pattern In my project i have a button,if i click on that button it will create a new button at run time and we can create any number of buttons there. Creating mutliple buttons is working and now am trying to move that controls at runtime where ever...

Triggering Silverlight Prism command with a keyboard shortcut

Hello, Does anybody know whether one can trigger prism command with a shortcut? What I mean is I want to be able to define binding of a command to keyboard shortcut in declarative manner, like ClientUI does: Are there any opensource libraries for that purpose? Or maybe code samples? I found this question but I don't think that it an...

Databinding Issue With Custom ObservableCollection Properties

I'm making a small personal finance program that uses "envelopes" as the budgeting method. I'm mostly doing this as a means to learn WPF & MVVM. I've run into a problem where I can't databind to the custom properties I created in my custom ObservableCollection, seen here: public class ObservableEnvelopeCollection : ObservableCollection<...

Getting Silverlight MVVM working with Expression Blend design time data?

I am a big proponent of the MVVM pattern with Silverlight. Currently I wire the ViewModel up to the View by newwing up the ViewModel in the code behind of the view, thusly: public partial class SomePage : UserControl { public SomePage() { InitializeComponent(); // New up a ViewModel and bind to layout root ...

WPF MVVM: Notifying the View of a change to an element within an ObservableCollection?

Calling OnPropertyChanged for an ObservableCollection only works when there has been some change to the properties of the collection, not the objects it contains (add, remove, clear, etc). Is there any way to notify the View that there has been a change to an item within the collection? ...

Add editing to MVVM in a hierarchical data structure

This question is a follow-up of this older one, and it's more of a confirmation than an open question. My ViewModel instance has a private instance of the Model, _modelInst. The ViewModel has exclusive access to the Model's data during editing (so the Model doesn't need to implement INotifyPropertyChanged). Now there are three ways I c...

getting checked checkboxes values mvvm light wpf

Hi, I have one usercontrol where am showing the main categories as buttons from the database. By clicking on Main Category button, a new user control is getting opened with list of items in that respective category clicked. I am binding the Item Names of that category in a xaml using TexbBlock and also am showing the checkboxes with eac...

How do I bind a generic window to an arbitrary view model at runtime, using DataTemplates?

I have a large number of ViewModel classes. For each of these classes, there is a corresponding .xaml file which is a 'UserControl'. In my App.xaml, I have them registered as DataTemplates, like so: <DataTemplate DataType="{x:Type viewModel:MainMenuViewModel}"> <view:MainMenuView/> </DataTemplate> With the idea being that WPF w...