I've got the following MainView.xaml file that works well as a MVVM menu switcher. I've got these pairs:
Page1View / Page1ViewModel
Page2View / Page2ViewModel
in my MainViewModel I fill an ObservableCollection with both ViewModels, then when the user clicks the Next button, it calls NextPageCommand in MainViewModel which switches out...
If you use the DelegateCommand in the MVVM Template and build menus dynamically as in the code below, then the DelegateCommand will not fire when the user clicks on the icon area on the MenuItem.
Is there anyway to either fix this or make the icon area (to the left of the header) disappear?
MainView.xaml:
<Window x:Class="TestMenuMvvm...
I have a WPF application which has a MainView.xaml Window which loads numerous page objects at runtime, loads them into ViewModels, and displays them dynamically in the menu.
My MainViewModel has an ObservableCollection of ViewModels and I bind these each to their appropriate Views in the MainView.xaml file.
However, is there a way to ...
I created a MVVM test application which at runtime reads an XML file to create a menu dynamically and based on what the user selects, loads in that page's UserControl dynamically. The result is a nice MVVM pattern that allows you to have one View/ViewModel pair per page all defined in an XML file. Very nice.
So now I just added the abil...
I'm trying to implement drag and drop functionality in a Surface Application that is built using the MVVM pattern. I'm struggling to come up with a means to implement this while adhering to the MVVM pattern. Though I'm trying to do this within a Surface Application I think the solution is general enough to apply to WPF as well.
I'm tr...
In a WPF application using MVVM, I have a usercontrol with a listview item. In run time, it will use databinding to fill the listview with a collection of objects.
What is the correct way to attach a double click event to the items in the listview so that when an item in the list view is doubleclicked, A corresponding event in the view ...
I've been doing a prototype in WPF without using MVVM. It's got to such a size now that I'm refactoring it to use MVVM.
When I started the project, I jumped straight in and created UserControls for lots of things.
I'm now breaking things in Views and ViewModels. But, I'm ending up with Views that contain UserControls; the UserControl...
Ok I really would like to know how expert MVVM developers handle an openfile dialog in WPF.
I don't really want to do this in my ViewModel(where 'Browse' is referenced via a DelegateCommand)
void Browse(object param)
{
//Add code here
OpenFileDialog d = new OpenFileDialog();
if (d.ShowDialog() == true)...
I'm trying to understand the basic MVVM design approach, but I dont' understand where is the best tips for work with CRUD operations.
a. Create a ViewModel with abstract of properties and in this ViewModel implement CRUD methods?
b. Create ViewModels base and then add properties for ObservableCollections of Viewmodel?.
Can you said me...
I"m trying to wrap my head around MVVM. I understand a lot of it, but I'm having difficulty grasping one aspect: Setting DataContext.
I want to show an view with a particular object. The user doesn't get to decide what is visible, so I need to create the view in code. Then, I want to set the DataContext of the view to an object (for b...
Hey there,
I am using the Model View View-Model pattern for a WPF app. I have a ViewModel (set as a pages DataContext) with two properties, one of which is an Entity with a PropertyChanged event. In the event handler i set the value of the other property (a boolean) to some value.
Now the Button and TextBox properties are binding fine ...
Is using WPF navigation in standalone applications is best practice? And can it be used with WPF MVVM pattern?
...
I'm currently converting a small WPF project to MVVM. I have a List<CustomObject> in the ViewModel of the main window that my ItemsControl binds to and uses a DataTemplate to build the UI of each element. My old code used an event handler inside the DataTemplate to handle a click event. I want to use some kind of command binding to el...
In MVVM pattern I don't want to think about the view while creating the model. So I use public properties with data stored in ILists and so on.
But then my viewmodel isn't informed of changes done to these lists on model side.
Should I use ObservableCollections in my model instead? But this seems strange to me.
...
I have an application which has a similar interface to Visual Studio, in that there's a list of documents that can be opened, edited an saved. Each document can be of different types and has different editors.
I also have a general Save MenuItem. What I want to do is have the Save command only save the active document. Is there a stand...
Hi,
I am learning MVVM using sample created by Josh Smith at http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
I wanted to add a functionality of update in the existing code,
Like when user sees data on the Grid of 'All Customers' user can edit particular record by double clicking it, double click will open up new tab (same view/...
The following code-behind binding works for the SmartFormView user control:
View:
<UserControl x:Class="CodeGenerator.Views.PageItemManageSettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:v="clr-namespace:CodeGenerator.Views"
xmln...
I'm pretty new to WPF and using the MVVM design pattern. To help learn this, I'm developing a simple dice-rolling application.
Right now, I have a Dice class and a DiceViewModel class. I also have a MainWindowViewModel class that contains an observable collection of DiceViewModels.
When a user clicks the "Roll" button, it launches a ...
I have a ListBox bound to an observable collection of DiceViewModel. Whenever I click a button to add a new item, the ListBox displays the new item like I expect. Everything so far is working well.
<ListBox
ItemsSource="{Binding Path=AllDice}"
DisplayMemberPath="Value"/>
However, I have another button to roll all existing dice. ...
when using mvvm pattern, when we have lists we use ObservableCollection<>.
my question is when should i call to
CollectionViewSource.GetDefualtView(theCollection);
to get the view that i can filter and sort and do some other cool stuff.
if i dont work with mvvm i'll do it in window.load
...