mvvm

Remove SelectedItems from a ListBox via MVVM RelayCommand

I have a list of items in a WPF ListBox. I want to allow the user to select several of these items and click a Remove button to eliminate these items from the list. Using the MVVM RelayCommand pattern, I've created a command with the following signature: public RelayCommand<IList> RemoveTagsCommand { get; private set; } In my View, I...

I'm Getting Cannot set Visibility or call Show, ShowDialog Exception

I'm using WAF (Wpf Application Framework) to create a dialog as shown in the ModelView sample application. I am trying to put up a simple AboutBox by mirroring the code for putting up the CreateEmailAccountWizard dialog box. My About box shows up fine the first time, but when I call it again from the menu, it gives me the following exc...

Is it possible for the View to subscribe ViewModel CLR event?

Sometimes a view model needs to raise notifications, that a view should handle and do something in response, esp. when these can't be modeled as properties and property change notifications. Anything in MVVM Light that can allow the view to listen to events and translate view model notifications into user interface actions via declarati...

RelayCommand sender from ItemsControl item

I've been using MVVM's RelayCommand with success to bind actions to XAML, but I'm having a small problem with my ItemsControl. <ItemsControl ItemsSource="{Binding Devices}" > <ItemsControl.ItemTemplate> <DataTemplate> <Grid Width="100" Margin="4" > <Button Command="{Binding Pat...

WPF MVVM Pattern, ViewModel DataContext question

I used this side to create my demo application http://windowsclient.net/learn/video.aspx?v=314683 The site was very useful in getting my started and in their example, they created a file called EmployeeRepository.cs which appears to be the source for the data. In their example, the data was hard-wired in code. So I'm trying to learn how...

how to reference drageventArgs in xaml as command parameter with silverlight

Hi, on my silverlight 4 app I am trying to link up the drop event on a list box to my viewmodel. I am using expression blend 4's event trigger and invokecommandaction to hook up the drop event. Setting break points on my viewmodel, I can see the relevant function is fired when I drag a file onto the list box, however I cant seem to ge...

Silverlight data-driven application with NHibernate

Hi Guys, this is more of a subjective Question, but I'll ask it anyway. I'm about to develop a very data-centric application that has to run inside the browser. The frontend will be Silverlight, backed by a Fluent NHibernate service that runs server side. The problem here is: Wherever I look for data-driven silverlight app I wind up fi...

Dynamically adding Views in Silverlight & MVVM

Hi all, I am starting to re-write my whole silverlight business application in the MVVM pattern; My first stop-point is this: I have a page (View1) with corresponding ViewModel1 (with a property 'IEnumerable AllData'); Now, within this View, I want to have i.e. a tree-view control, in which one node will be populated with another View...

MVVM Binding Orthogonal Aspects in Views e.g. Application Settings

I have an application which I am developing using WPF\Prism\MVVM. All is going well and I have some pleasing MVVM implementations. However, in some of my views I would like to be able to bind application settings e.g. when a user reloads an application, the checkbox for auto-scrolling a grid should be checked in the state it was last tim...

Bind event in custom WPF control to command in ViewModel

Hi, I have a custom control that has an event. I have a window using that custom control. The window is bound to a viewmodel. I would like to have the event from the custom control direct to an ICommand on my viewmodel. I am obviously being dense here as I can't figure out how to do this. Any assistance is most welcome. Thanks ...

How to Bind MouseDoubleClick Event

How can I bind a MouseDoubleClick event of a DataGrid to a delegate command and get the selected item of that grid.? I want to do this in XAML file as I'm using Prism 2.0 and MVVM pattern. ...

Silverlight MVVM conversion from WPF

I was reading this article - http://msdn.microsoft.com/en-us/magazine/dd419663.aspx And I came across this piece of code in the WPF Demo application that came with the article. This template applies a CustomerView to an instance of the CustomerViewModel class shown in the main window. <DataTemplate DataType="{x:Type vm:CustomerViewMod...

Wpf binding with nested properties

ViewModel I have a property of type Member called KeyMember. The 'Member' type has an ObservableCollection called Addresses. The Address is composed of two strings - street and postcode . View I have a ListBox whose item source need to be set to ViewModels's KeyMember property and it should display the Street of all the Past Addresses...

Refreshing Read-Only (Chained) Property in MVVM

I'm thinking this should be easy, but I can't seem to figure this out. Take these properties from an example ViewModel (ObservableViewModel implements INotifyPropertyChanged): class NameViewModel : ObservableViewModel { Boolean mShowFullName = false; string mFirstName = "Wonko"; string mLastName = "DeSane"; private rea...

Should I use ICommand or Expression.Interactions InvokeCommand for MVVM in Silverlight 4?

I'm about to embark on a new project in Silverlight 4, and definitely want to take advantage of the MVVM pattern, now I've finally grasped the basics. For implementing commands in Silverlight 4 it seems there are rather a lot of options ranging from the new built-in Command/ICommand option on the Button, over the InvokeCommand defined i...

MouseDoubleClick event in View

How do I bind MouseDoubleClick event of wpfdatagrid in the view as I'm using mvvm and Prism 2. ...

What is the best way to detect if my page needs saving - ussing WPF MVVM

I have an application where you can open many different items (like in excel you can open many different tabs) If an item or "tab" is modified I want to detect the changes and allow the use to save or prompt if the user closes without saving. Maybe enable/disabling save button when a save is available/not available. I am using c# WPF wit...

MVVM Focus To Textbox

How would I set focus to a textbox without specifying the name for that textbox? At the moment I am doing the following <Window FocusManager.FocusedElement="{Binding ElementName=Username}"> <Grid> <TextBox Text="{Binding Username}" Name="Username" /> </Grid> </Window> Is there any way of doing this without ...

MVVM - Master/Detail scenario with Navigation and Blendability

Hi, I'll start off with what I want so it may be simpler to understand: I have a Page (Master.xaml) that has has a listbox of PersonViewModel. When the user selects a PersonViewModel from the listbox, I want to Navigate to a details (Details.xaml) page of the selected PersonViewModel. The details page does some extra heavy lifting th...

Value of text box disapears - binding viewmodel to a tab (content control)

Based on the MVVM example by Josh Smith, I have implemented the multi tab option which binds to a different tab to a different view model using a simple datatemplate that binds a viewmodel to a view. <DataTemplate DataType="{x:Type fixtureVM:SearchViewModel}"> <SearchVw:SearchView/> </DataTemplate> The issue that I'm having, is...